how to use curl with facebook graph api

Discussion in 'PHP' started by moheballah, Dec 3, 2011.

  1. #1
    hi,

    i need to publish message in my wall using php

    when i use this code

    $url = 'https://graph.facebook.com/oauth/access_token?client_id='.$this->facebook_client_id.'&client_secret='.$this->facebook_client_secret.'&grant_type=client_credentials';
    		
        	$ch = curl_init();
        	curl_setopt($ch, CURLOPT_URL, $url);
        	$get = curl_exec($ch);
        	curl_close($ch);
        	
        	$access_token = str_replace('access_token=', '', $get);
        	
        	$ch = curl_init();
    		$postFields = array('access_token' => $access_token, 'message' => 'test message');
    		
    		curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/profile_id_here/feed");
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    		curl_setopt($ch, CURLOPT_VERBOSE, true);
    		
    		$tt = curl_exec($ch);
    		curl_close($ch);
    PHP:
    i get this error

     
    moheballah, Dec 3, 2011 IP
  2. moheballah

    moheballah Member

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    i did it using post in curl

    curl_setopt($ch, CURLOPT_POST, TRUE);
     
    moheballah, Dec 3, 2011 IP