如何在墙上添加一张照片,而图表api

如何在墙上添加一张照片,而图表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
            ) );