發佈到Facebook頁面我已經建立了一個腳本通過PHP通過捲曲
發佈消息到我的Facebook頁面它工作了近2年
現在,恕不另行通知它停止工作。
我正確地得到access_token
但第二部分返回該錯誤
{"error":{"message":"An unknown error has occurred.","type":"OAuthException","code":1}}
下面是代碼
$url = "https://graph.facebook.com/oauth/access_token";
$postString = "client_id=KEY&client_secret=SECRET&type=client_cred";
$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);
$access_token = str_replace("access_token=", "", curl_exec($curl));
$titolo = 'Test';
$link_pulito = 'test.html';
$testo_fb = 'Test';
$attachment = array(
'access_token' => $access_token,
'message' => 'MESSAGE',
'name' => 'test',
'link' => 'http://www.test.com/workshop/',
'description' => 'test test test',
'picture'=>'http://www.test.com/77818763a19937bdd82b25f26cef2522.jpg'
);
// set the target url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/MYPAGE/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); //to suppress the curl output
$result= curl_exec($ch);
curl_close ($ch);
您確定能正確獲取訪問令牌嗎?你只是假設curl_exec()調用工作,並沒有返回一個布爾值false。 –
是的,我可以回顯access_token並看到它 –