如何在墙上添加一张照片,而图表api [英] How to include on the wall a photo post though graph api

查看:113
本文介绍了如何在墙上添加一张照片,而图表api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用图形API来发布图片时,一切都可以。这张照片正好在专辑中。
问题是墙上没有提到图片。它只是包含在专辑中,没有任何东西在墙上。

When i use graph api to post a picture, everything is ok. The photo is right in the album. The problem is that the picture is not mention on the wall. It's just include in the album with nothing on the wall.

我使用这样的基本代码:

I use basic code like that :

            $facebook->setFileUploadSupport(true);     
            $file = "@".realpath(PIC);  

            $result = $facebook->api(
            '/PAGE_ID/photos/',
            'post',
            array('access_token' => $access_token,
                  'type' => 'status',
                  'message' => stripslashes(MESSAGE),
                  'image' => $file
                )
            );

你知道如何强制图片和消息出现在墙上作为状态? / p>

Do you know how to force the picture and the message to appear on the wall as a status?

推荐答案

我想出的唯一解决方法是获取Wall Photos相册的ID,并将照片发布到该相册上。

The only workaround could i figure out is to get Wall Photos album's ID and post photo to that album to appear on wall..

不幸的是没有更简单的方法来强制它。以下是示例代码:

Unfortunately there is no easier way to force it out. Here is the sample code:

    $result = $facebook->api('/'.$pageID.'/albums/?access_token='.$access_token, 'get' );
    $albumArr = $result['data'];
    $albumID = 0;

    for($j = 0 ; $j < sizeof($albumArr) ; $j++) {
        if ($albumArr[$j]['type'] == 'wall') {
            $albumID = $albumArr[$j]['id'];
        }
    }

    $result = $facebook->api('/'.$albumID.'/photos/', 'post' , array('access_token' => $access_token,
              'type' => 'status',
              'message' => stripslashes(MESSAGE),
              'image' => $file
            ) );

这篇关于如何在墙上添加一张照片,而图表api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆