douzhong1730 2013-02-14 18:25
浏览 46
已采纳

在页面时间轴上传Facebook照片(PHP)

I have a cache of pictures in my website, and I need to upload these photos to my Facebook fan page 4-5 times a day. My code creates an album and also uploads the photos to the album, however, these photos do not appear in the timeline.

So my question is, how do I upload photos to my fan page such that they appear on the timeline, on the wall. The language in use is PHP

Any help is greatly appreciated.

Thanks

Edit 1: Here is the code:

<?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);

?>
  • 写回答

1条回答 默认 最新

  • dpwh11290 2013-02-14 22:35
    关注

    Ok, so I guess you tried removing the no_story and found that it didn't affect the timeline. Thats what I found too.

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题