<?php
$appId = 'XXXXX';
$pageId = 'XXXXX';
$secret = 'XXXXX';
$token = 'XXXXX';
$data = array(
'access_token' => $token,
'description' => 'test_description',
'link' => 'http://www.google.co.uk',
'message' => 'test_message',
'name' => 'test_name'
);
try
{
require_once 'facebook/facebook.php';
$sdk = new Facebook(
array(
'appId' => $appId,
'secret' => $secret,
'cookie' => true
)
);
$post = $sdk->api('/'.$pageId.'/feed', 'POST', $data);
print_r($post);
}
catch (FacebookApiException $e)
{
echo $e;
}
?>
使用上面的代码,我试图在我的页面墙上发布指向 Google 的链接。当我运行代码时,我得到了我所期望的 ID 响应。然而,尽管拥有有效的 ID,但页面上没有显示任何内容。
如果我删除“链接”并重试,我会得到另一个 ID,并且帖子会显示在我的页面上。
难道我做错了什么?
为什么“链接”值会导致返回ID但不显示帖子?
这是 Facebook 看到的(通过 Graph API 浏览器查询):
{
"id": "484729401573953",
"created_time": "2013-01-08T12:03:27+0000",
"caption": "www.readesresidential.com",
"description": "test_description",
"from": {
"name": "David Reade",
"id": "100003544363105"
},
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
"link": "http://www.readesresidential.com/brookside-crescent-northop-hall-ch7-6hw-ps03009/",
"message": "test_message",
"name": "test_name",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQC7MpbP6aNe2CVP&w=90&h=90&url=http%3A%2F%2Fwww.readesresidential.com%2Fframework%2Fstatic-487d%2F2%2Fimg%2Fv3%2Ffacebook.png",
"privacy": {
"description": "Friends",
"value": "ALL_FRIENDS",
"allow": "",
"deny": "",
"networks": "",
"friends": ""
}
}
我可以看到它说“ALL_FRIENDS” - 这可能是导致帖子不显示的原因吗?您不能与页面成为朋友,可以吗?
我现在已将“数据”变量修改为以下内容:
$data = array(
'access_token' => $token,
'description' => 'test_description',
'link' => 'http://www.readesresidential.com/go/ps02618',
'message' => 'test_message',
'name' => 'test_name',
'privacy' => array(
'value' => 'EVERYONE'
)
);
来自 Graph API 浏览器的响应是:
{
"id": "454654274601000",
"created_time": "2013-01-08T12:14:52+0000",
"caption": "www.readesresidential.com",
"description": "test_description",
"from": {
"name": "David Reade",
"id": "100003544363105"
},
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
"link": "http://www.readesresidential.com/church-street-tarvin-ch3-8eb-ps02618/",
"message": "test_message",
"name": "test_name",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQC7MpbP6aNe2CVP&w=90&h=90&url=http%3A%2F%2Fwww.readesresidential.com%2Fframework%2Fstatic-487d%2F2%2Fimg%2Fv3%2Ffacebook.png",
"privacy": {
"description": "Public",
"value": "EVERYONE",
"allow": "",
"deny": "",
"networks": "",
"friends": ""
}
}
即使帖子现在是“公开的”并且我使用了一个全新的 URL,它仍然没有显示。
这可能是 Facebook 的错误吗?