1

这个应用程序使用 PHP 和 Facebook 的 PHP API 实现发布到用户的时间线。这已经工作了好几个星期了。

以下 PHP 代码用于发布消息:

if($hasPhoto === TRUE)
{
    // Post to FB with picture
    $facebook->setFileUploadSupport(true);

    $result = $facebook->api("/me/photos", "post", array(
        'message'   => $message,
        'place'     => $place,
        'source'    => '@'  . $photo
    ));
} 
else 
{
    // Post to FB without picture
    $result = $facebook->api("/me/feed", "post", array(
        'message'   => $message,
        'place'     => $place
    ));
}

这工作正常,除了 $result 有两种格式:

array ('id' => '103240856515XXX', )
array ('id' => '100004900175XXX_103239809849XXX', )

Graph API 文档告诉我们以下内容:

A post from Facebook Platform:  https://graph.facebook.com/19292868552_10150189643478553
A status message on the Facebook Page: https://graph.facebook.com/10150224661566729

这意味着使用的 PHP 代码会生成帖子或状态消息。我看不到短信、照片、日期或作者之间有任何关系。这似乎是随机发生的。

下面从我们的数据中展示了 id 的格式和是否附上照片之间的关系。

select count(*) from fbposts where facebookpostid like '%\_%' and hasphoto = 1;  -- 90
select count(*) from fbposts where facebookpostid like '%\_%' and hasphoto = 0;  -- 87
select count(*) from fbposts where facebookpostid not like '%\_%' and hasphoto = 1;  -- 47
select count(*) from fbposts where facebookpostid not like '%\_%' and hasphoto = 0; -- 54

为什么会发生这种行为?如何强制发帖?这是相关的原因是因为 Post 确实有我想查询的 Privacy 属性。

更新: 查询由 FB API 给出的状态消息 545778052106XXX 和照片,给了我:

{
  "id": "545778052106XXX", 
  "from": {
    "name": "Jeffrey Krist", 
    "id": "100000226354XXX"
  }, 
  "name": "My message!", 
  "picture": "http://photos-f.ak.fbcdn.net/hphotos-ak-ash3/522827_545778052106XXX_1151562XXX_s.jpg", 
  "source": "http://sphotos-f.ak.fbcdn.net/hphotos-ak-ash3/s720x720/522827_545778052106XXX_1151562XXX_n.jpg", 
  "height": 720, 
  "width": 720, 
  "images": [
    {
      "height": 2048, 
      "width": 2048, 
      "source": "http://sphotos-f.ak.fbcdn.net/hphotos-ak-ash3/s2048x2048/522827_545778052106XXX_1151562XXX_n.jpg"
    },  .. lots more
  ], 
  "link": "https://www.facebook.com/photo.php?fbid=545778052106402&set=p.545778052106XXX&type=1", 
  "icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPXXX.gif", 
  "place": {
    "id": "182665821805XXX", 
    "name": "A company name", 
    "location": {
      "street": "My street 13", ..
    }
  }, 
  "created_time": "2012-11-01T08:35:20+0000", 
  "updated_time": "2012-11-01T08:35:20+0000", 
  "comments": ...
  "likes": ...
}

使用 FB API 中的 id 查询帖子消息给了我:

{
  "id": "100003331805XXX_299609210160XXX", 
  "from": {
    "name": "Some name", 
    "id": "100003331805XXX"
  }, 
  "message": "My message", 
  "picture": "http://photos-e.ak.fbcdn.net/hphotos-ak-ash3/560724_299609200160XXX_789651XXX_s.jpg", 
  "link": "https://www.facebook.com/photo.php?fbid=299609200160XXX&set=a.285494101571XXX.69331.100003331805XXX&type=1&relevant_count=1", 
  "name": "Photo album name", 
  "icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPXXX.gif", 
  "actions": [
    {
      "name": "Comment", 
      "link": "https://www.facebook.com/100003331805XXX/posts/299609210160XXX"
    }, 
    {
      "name": "Like", 
      "link": "https://www.facebook.com/100003331805XXX/posts/299609210160XXX"
    }
  ], 
  "privacy": {
    "value": "ALL_FRIENDS", ...
  }, 
  "place": {
    "id": "174171872642XXX", ...
  }, 
  "type": "photo", 
  "status_type": "added_photos", 
  "object_id": "299609200160XXX", 
  "application": {
    "name": "My app", ...
  }, 
  "created_time": "2012-12-21T22:33:59+0000", 
  "updated_time": "2012-12-21T23:30:39+0000", 
  "likes":  ...
  "comments": ...
}

查询一个组合 id,_ ('100000226354XXX_545778052106XXX'),它是带有照片的消息,给我:

{
  "error": {
    "message": "Unsupported get request.", 
    "type": "GraphMethodException", 
    "code": 100
  }
}
4

1 回答 1

0

当每个状态消息都是一个帖子对象时,不需要强制发布。

状态消息对象10100948019328597

发布对象userid_10100948019328597

状态消息对象

{
  "id": "10100948019328597", 
  "from": {
    "name": "phwd", 
    "id": "13608786"
  }, 
  "message": "Happy Thanksgiving you cool Canadians!", 
  "updated_time": "2012-10-08T23:17:27+0000", 
  "likes": {
    "data": [
    ], 
    "paging": {
      "next": 
    }
  }
}

发布对象

{
  "id": "13608786_10100948019328597", 
  "from": {
    "name": "phwd", 
    "id": "13608786"
  }, 
  "message": "Happy Thanksgiving you cool Canadians!", 
  "actions": [
    {
      "name": "Comment", 
      "link": "http://www.facebook.com/13608786/posts/10100948019328597"
    }, 
    {
      "name": "Like", 
      "link": "http://www.facebook.com/13608786/posts/10100948019328597"
    }
  ], 
  "privacy": {
    "description": "Public", 
    "value": "EVERYONE", 
    "friends": "", 
    "networks": "", 
    "allow": "", 
    "deny": ""
  }, 
  "type": "status", 
  "status_type": "mobile_status_update", 
  "created_time": "2012-10-08T23:17:28+0000", 
  "updated_time": "2012-10-08T23:17:28+0000", 
  "likes": {
    "data": [
     ]
  }, 
  "comments": {
    "count": 0
  }
}

最好的检查方法是比较/me/statusesvs/me/posts

于 2012-12-23T15:14:06.210 回答