user1951426
user1951426

Reputation:

Uploading Picture to page album is working But posting a picture on wall is not

Error am getting OAuthException: (#100) picture URL is not properly formatted

I have got a very strange problem,I am able to upload pictures on my page album using graph api,but when i try to post a picture using graph api,it is not working,

Note when i post a message or a link to wall,its getting posted,the problem is only with the picture.

Here i am putting both the code snippets:

1,This is when i am trying to upload a picture to page album(working):

$facebook->setFileUploadSupport("http://apps.facebook.com/pagecron");
$x=realpath($_FILES['source']['tmp_name']);
$parameters = array('message' => $_POST['message'],'source' =>'@' . $x );
$parameters['access_token'] = $_SESSION['active']['access_token'];
$check=$facebook->api('/'.$_SESSION['active']['id'].'/photos/','POST',$parameters);

2,This is when i am trying to post a picture to the wall(Not Working):

$img = realpath($y);
$facebook->setFileUploadSupport("http://apps.facebook.com/pagecron");
$x=realpath($_FILES['source']['tmp_name']);
$parameters = array('message' => $_POST['message'],'picture' =>'@' . $x );
$parameters['access_token'] = $_SESSION['active']['access_token'];
$check=$facebook->api('/'.$_SESSION['active']['id'].'/feed/','POST',$parameters);

Upvotes: 2

Views: 747

Answers (2)

World Gamer
World Gamer

Reputation: 333

Ist Thing: You need to POST to /TIMELINE_PHOTOS_ALBUM_ID/photos.

2nd Thing:There may not be an album with such a name,so you should ist create it(After checking).

How To:

 $albums =$facebook->api('pageid/albums',GET,array('access_token'=>'access_token');      
 foreach($albums['data'] as $album)
 {
   if($album['name'] == 'TIMELINE_PHOTOS')
   {
      $uid = $album['id'];
   }
 }
if(isset($uid) && $uid !=0)
{
  //mean album is there so use that uid to post your photo
}
else 
{
    //create your album with that name and use its id
}

Upvotes: 2

cpilko
cpilko

Reputation: 11852

It appears that if you want to post a photo to a user's wall, you need to POST to /TIMELINE_PHOTOS_ALBUM_ID/photos.

There doesn't appear to be a shortcut here to get at this. You need to search through the results of /USER_ID/albums to find the album_id of album named "Timeline Photos" (or get it using FQL).

The documentation says that albums have a limit of 200 photos. I'm not sure what happens if a user has more than 200 photos in their "Timeline Photos" album. I couldn't find a friend to inspect this against.

Upvotes: 1

Related Questions