<?php
require_once 'Facebook/autoload.php';
require_once 'Facebook/Authentication/AccessToken.php';
$fb = new Facebook\Facebook([
'app_id' => '2452542542fsrgrgrg',
'app_secret' => '5245dffhdhr5535353535',
'default_graph_version' => 'v2.2',
]);
$linkData = [
'link' => 'http://www.example.com',
'message' => 'User provided message',
];
$helper = $fb->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken();
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post('/me/feed', $linkData, $accessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
echo 'Posted with id: ' . $graphNode['id'];
?>
我收到此错误“Facebook SDK返回错误:您必须提供访问令牌。”我试图搜索,我没有任何可靠的答案。任何有想法的人都可以分享。