This is my code and I tried to \"Curl\" it (file_get_contents
didn\'t work for some reason) but since i can\'t really get Curl to work, I came
You can't just pass the url to the CURLOPT_POSTFIELDS
option. The base url should be set in the CURLOPT_URL
option, and the parameters in CURLOPT_POSTFIELDS
(using PHP's http_build_query
function to generate the encoded query string);
So your curl function could look something like this:
function curl($url,$parms)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parms, null, '&'));
}
And then you would call it like this:
$token_url="https://graph.facebook.com/oauth/access_token";
$token_parms = array(
"client_id" => $app_id,
"client_secret" => $app_secret,
"redirect_uri" => $post_login_url,
"code" => $code
);
$response = curl($token_url, $token_parms);