duanfu1942 2011-09-14 08:04 采纳率: 100%
浏览 34

为stream.publish寻找图片附件php API feed

I am desperately looking for image attachment php api feeds for my facebook app.

Basically what I am trying to do is send an image attachment, along with an automatic "post to friends wall" action.

The idea behind it is that a user sends a "virtual burger" to their friends wall, with a message offering them a discount.

This is a snippet of the code that successfully sends the message, but I can't get the attachment to work.

if($_REQUEST['friend_1']!='' && $_REQUEST['friend_1']!="Start typing a friend's name") {
    try {
        $fql1    =   "select name from user where uid=" . $_REQUEST['friend_1'];
        $param1  =   array(
            'method'    => 'fql.query',
            'query'     => $fql1,
            'callback'  => ''
        );
        $fqlResult1   =   $facebook->api($param1);
        $friend_1_name = $fqlResult1[0]['name'];
        $statusUpdate = $facebook->api('/'.$_REQUEST['friend_1'].'/feed', 'post', array('link' => $fanpageURL, 'name' => 'Have a virtual Unity Burger.', 'description' => " ".$user_name." just sent you a virtual Unity Burger. If you would rather have the real thing then come add your name on the Unity list and we will give you a 20% discount on your next visit and an exclusive Unity keyring.", 'properties' => '', 'cb' => ''));
    } catch (FacebookApiException $e) {
        //echo "Notification not send to user ".$fqlResult1[0]['name']."<br>";
  • 写回答

1条回答 默认 最新

  • duanhuiuw12555 2011-09-14 09:16
    关注

    I think there are two ways to attach an image to a wall post.

    The first one is to define the meta og:image in the target page and post the link to the friends wall. Facebook will query the target and grab the Open Graph info displaying it in the wall. You can test this with the Facebook Debugger.

    The meta property should look like this:

    <meta property="og:image" content="http://url.to/image" />
    

    You can also define other Open Graph properties like title, description, etc.

    The second way to attach the image to the post is to include the picture parameter in the Graph API call. In your code you only define some parameters (link, name, description...) but you can also send picture, caption, message...

    So your API call could be like this:

    $params = array(    'access_token' => '',
                        'message'   =>  '',
                        'link'      =>  '',
                        'picture'   =>  '',
                        'name'      =>  '',
                        'caption'   =>  '',
                        'description'   =>  ''
    );
    
    $wallPost = $facebook->api('/'.$to.'/feed', 'post', $params);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度