Vincent Mallet
Vincent Mallet

Reputation: 11

How to include on the wall a photo post though graph 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
                )
            );

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

Upvotes: 1

Views: 919

Answers (1)

Tolga Arican
Tolga Arican

Reputation: 476

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

Upvotes: 1

Related Questions