1

我的网站中有图片缓存,我需要每天将这些照片上传到我的 Facebook 粉丝页面 4-5 次。我的代码创建了一个相册并将照片上传到相册,但是,这些照片不会出现在时间轴中。

所以我的问题是,我如何将照片上传到我的粉丝页面,以便它们出现在时间轴上,在墙上。使用的语言是 PHP

任何帮助是极大的赞赏。

谢谢

编辑1:这是代码:

<?php   
require 'facebook.php';
$facebook = new Facebook(array(
    'appId'  => "AAAAAAAAAA",
    'secret' => "BBBBBBBBBB",
));

$fanpage_token = "ZZZZZZZZZZZZZZZZZZZZZZZZZZ";

$facebook->setFileUploadSupport(true);

//Create an album
$album_details = array(
        'message'=> 'test album',
        'name'=> 'album'
);
$create_album = $facebook->api('/PAGE_ID/albums', 'post', $album_details);

$album_uid = $create_album['id'];

echo $album_uid;

 $img = '7newx.jpg';
  $args = array(
   'message' => 'Random message',
   'image' => '@' . $img,
   'aid' => $album_uid,
   'no_story' => 1,
   'access_token' => $fanpage_token
  );

  $photo = $facebook->api($album_uid . '/photos', 'post', $args);

?>
4

1 回答 1

5

好的,所以我猜您尝试删除 no_story 并发现它不会影响时间线。这也是我发现的。

What you have to do is make another post, but this time, as a link. You need to use your array $photo, which was returned from your first post. If you examine that you should see it has a single element called ['id'], containing the id of your uploaded photo.

You need to turn that into a link that facebook would use to display. This is simple.

if (isset($photo['id']))
{
$message = "My latest photo";
$link = "https://www.facebook.com/photo.php?fbid=".$photo['id'];
$attachment = array
(
'access_token'=>$fanPageAccessToken,
'type' => 'photo',
'message' => $message,
'link' => $link 
);

$result = $facebook->api($fanPageId.'/links/','post',$attachment);
}

I am assuming you can work out what $fanPageAccessToken and $fanPageId are.

If you do that, you should get what you want.

于 2013-02-14T22:35:00.167 回答