Facebook api自动转寄
我使用facebook api从我的网站自动发布。 这是我的代码,然后我解释我的问题:Facebook api自动转寄,facebook,facebook-graph-api,Facebook,Facebook Graph Api,我使用facebook api从我的网站自动发布。 这是我的代码,然后我解释我的问题: require_once "Facebook/autoload.php"; $fb = new Facebook\Facebook([ 'app_id' => 'xxxxxxx', 'app_secret' => 'xxxxxxxxx', 'default_graph_version' => 'v2.2'
require_once "Facebook/autoload.php";
$fb = new Facebook\Facebook([
'app_id' => 'xxxxxxx',
'app_secret' => 'xxxxxxxxx',
'default_graph_version' => 'v2.2'
]);
$pageAccessToken = 'xxxxxxxxxxxxxxxxxxxxx';
$linkData = [
'link' => $link,
'message' => $message,
'picture' => $pic
];
try {
$response = $fb->post('/me/feed', $linkData, $pageAccessToken);
} catch (Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
} catch (Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
}
$graphNode = $response->getGraphNode();
我的问题是,这段代码有时有效,而不是一直有效。
有时我会看到这些错误:
Severity: Notice
Message: Undefined offset: 1
Filename: Http/GraphRawResponse.php
Line Number: 108
及
我转到api资源管理器,从下拉列表中选择我的页面,在底部下拉列表中选择访问页面标记,然后再次选择我的页面名称。
并将生成令牌复制到我的页面访问令牌中
我不知道为什么有时候这个代码工作得很好,有时候却不行
有什么想法吗
tnx您只捕获了两个特定的异常-请确保也捕获一般异常,这样您就不会错过API可能报告的任何错误。@CBroe,实际上我使用API doc来编写这段代码,这段代码与日期完全一致……这并不意味着它涵盖了所有可能性。这些都是基本的例子。当这些东西不起作用时,你需要采取必要的步骤来找出原因。请从我说的开始。
Severity: 4096
Message: Argument 4 passed to Facebook\FacebookResponse::__construct() must be of the type array, null given, called in /home/deponews/public_html/application/controllers/Facebook/FacebookClient.php on line 225 and defined
Filename: Facebook/FacebookResponse.php
Line Number: 75