Facebook picture uploader (fanpage)

此生再无相见时 提交于 2019-11-28 14:15:31

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!