• rajendra jadhav
  • 0 Points
  • Member since 2013

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1


I am trying to get the following output in my code. I already have my instance url and access_token. In the documentation for Oauth2, it tells me to send a get request to the id url followed by an OAuth authorization HTTP header containing the access token. Can someone please give me a sample code on how can I send a get request to the id url? I am trying to get the url for the api endpoint. 

	"display_name":"Sample User",
		"body":"Working on OAuth 2.0 article"

 I used curl to do the request, but I can not seem to find out why it does not return anything. $url is my  id url and $access_token is my token.  The returning status is always 302 instead of 200. Please I need help on figuring why this is happening. I've red the oauth documentations so many times, but I still can not figure what is wrong. Please I would appreciate it if someone had a look at my code.

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
            array("Authorization: OAuth $access_token"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 200 ) {
        die("Error: call to URL $url failed with status $status, response $json_response, curl_error " .     curl_error($curl) . ", curl_errno " . curl_errno($curl));


  • September 12, 2011
  • Like
  • 0