簡體   English   中英

使用cURL(php)的Facebook身份驗證

[英]Facebook Authentication using cURL (php)

我正在嘗試使用cURL進行Facebook身份驗證,這是我的目的:

        $url = "https://graph.facebook.com/oauth/access_token";
        $postString = "?client_id=$client_id&redirect_uri=$redirect_uri&client_secret=$client_secret&code=$code";
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_FAILONERROR, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
        //curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $postString);
        $response = curl_exec($curl);

但每次它都返回false。

我對使用cURL很陌生,因此我可能會犯一些初學者的錯誤,但是我對為什么這根本不起作用感到困惑。

任何幫助將不勝感激!

這可能太明顯了,可能是拼寫錯誤,但是:

//curl_setopt($curl, CURLOPT_POST, 1);

應該沒有評論。

去除 ”?” 從您的帖子字符串的開頭..那應該解決它!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM