Examples of code to create an OAuth access token by using PHP.

Example Code

	#!/usr/bin/php
	<?php
	$host = 'http://engage.com/oauth/token';
	$key = 'XMLAPIENGAGE';
	$secret = 'PRODUCTION_USE';
	$refreshToken = 'ac1bfab0-f310-4161-9f6b-53cabac451a8';
	$fields = array(
	'client_id' => $key,
	'client_secret' => $secret,
	'refresh_token' => $refreshToken,
	'grant_type' => 'refresh_token'
	);
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $host);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, count($fields));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
	$json_result = curl_exec($ch);
	$result = json_decode($json_result);
	var_dump($result);
	?>

 

Join The Discussion

Your email address will not be published. Required fields are marked *