I am trying to upload a image to my fan pages wall using the PHP SDK, and also let other people upload pics to the page.
Here is what I have thus far,
PHP:
$img = realpath($y);
$facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);
$photo = $facebook->api('/FAN_PAGE_ALBUM_ID/photos', 'POST',
array(
'access_token' => $token,
'source' => '#' . $img,
'message' => 'This photo came from my app.'
)
);
When I try that nothing happens, even though I used a similar method to post to the fan pages wall, which worked fine, I also have the appropriate permissions, as far as I know... status_update,publish_stream,user_photos,offline_access ??
Any reason why this could be happening?
For you to be able to upload pictures to a page you are an administrator of, you would most likely need manage_pages permissions. I'm not sure you can have users upload pictures to a fan page from the graph api, although they can from the website so they should be able to.
You need this permission: manage_pages.
Related
I have recently noticed that facebook has started ignoring my og:image tag on my site. The image used is always larger than 200x200.
Here is an example page:
http://bit.ly/15CrOhS
http://bit.ly/1b8Mgbe
Seems to be alot of questions, but no answers. I've added all the og information and checked with the linter and it all goes through fine. So why does it choose to pick a random image?
I use the facebook api for PHP to send:
<?php
$link = 'http://www.mylinkaddress.com';
$msg = 'Check out my new photo. '.$link;
$get_oauth = "SELECT * FROM users_oauth_cred WHERE userid = ".$_SESSION['userid']." AND share = 1 AND oauth_access_token != ''";
$get_oauth = mysql_query_run($get_oauth);
$oauth = mysql_fetch_array($get_oauth);
# FACEBOOK
$facebook = new Facebook(array(
'appId' => FACEBOOKAPPID,
'secret' => FACEBOOKSECRET,
'cookie' => false,
));
$token = $oauth['oauth_access_token'];
try {
$result = $facebook->api(
'/me/feed/',
'post',
array('access_token' => $token, 'message' => str_replace($link,'',$msg), 'link' => $link)
);
}
catch(FacebookApiException $e) {}
?>
I had the same issue.
Go to Facebook Object Debugger, verify every issue pointed there, fix them all. This solved my problem.
http://goo.gl/ASBsAa
Testing your query with the facebook Graph API Explorer worked fine for me.
You could try to add the additional parameter 'picture' to your post and place the link to your image in it.
So facebook is forced to use this as image in the post.
$result = $facebook->api(
'/me/feed/',
'post',
array('access_token' => $token, 'message' => str_replace($link,'',$msg), 'link' => $link, 'picture' => 'http://images.ephotozine.com/gallery/2011/49/normal/52194_1323334048.jpg')
);
Reading through all the comments here, I think what's happened is the following.
Let me know how close I got. This is a shot in the dark. ;)
The first time you shared a URL to Facebook, the og:image wasn't set up perfectly, and Facebook selected a random image on the page, and cached it.
You then fixed the og:image tag, and tried to check the same URL.. FB then regurgitated the cached image.
I tried with both your links just now, and everything seems fine.
:{D
Just be patient. Facebook needs some time to crawl this image. It will not immediately show up in Facebook. If your image is not showing up in some days, just drop a note here.
Much testing and trying other bulk uploaders etc. Finally just decided to email facebook with details and screnshot. next day the issue has been resolved. So, make sure to try that from the help email through your facebook account. worked for me.
I'm building a Facebook App where the user selects an image that gets uploaded to my App's album for that user. Everything works fine, the picture gets uploaded and posted on the user's wall etc no problems there.
But, after the upload I try to fetch the newly uploaded photo using the ID I get as a response from the upload, and this is where I run into problems. FB simply tells me "Unsupported GET request".
Here's the relevant code I have:
<?php
# Works perfectly fine
$response = $fb->api('/me/photos', 'post', array(
'message' => 'Some message',
'source' => '#' . realpath('path/to/img.jpg')
));
# "Unsupported GET request"... :/ (SOMETIMES ??)
$photo = $fb->api('/' . $response['id']);
All the authentication etc obviously works (otherwise I wouldn't be able to upload at all) it's just fetching the photo that does not work.
I'm using the PHP and JS SDK:s simultaneously and I've tried with both. I started with JS and it never worked. However, the PHP call works sometimes.
Does anyone know what I'm doing wrong?
Edit: Ok so I skipped fetching the newly created photo and instead simply constructed a URL to it using the ID returned from the upload (all I was after was the photo object's link property anyway - I figured it was more future proof to use instead of constructing your own). However, even now when I redirect to http://www.facebook.com/photo.php?fbid=ID_GOES_HERE&makeprofile=1 sometimes (again :P) Facebook will tell me the "content is not available". After a Ctrl+R, however, it is. This seems to me that FB hasn't finished adding the new content even though my $fb->api('/me/photos', 'post'...-call has returned an ID.
Thoughts?
Well for me, it was just because the method to post photo seems to change :
https://developers.facebook.com/docs/reference/api/page/#photos
$facebook->setFileUploadSupport(true);
$picture = "#".realpath('path/to/the/photo');
$result = $facebook->api(
'/fb_id_of_the_page/photos/',
'post',
array('access_token' => 'access_token',
'message' => 'message',
'source' => $picture
)
);
Well, pretty strange because the same thing happen to me.
Work fine and 12 hours ago, completely down. I can't post anymore whereas i've got return id.
When I ask the graph api with the return id I got this :
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
Just to notice it's happe only when I post image. With link or status everything is fine.
Is FB api in trouble?
Is this possible to create a photo on user/page's timeline not by uploading said photo, but by providing a URL to an already uploaded image? My code so far is this:
$response = $fb->api ("/$page_id/photos", 'post', array (
'name' => $_description,
'source' => $_image_path
));
This results in OAuthException #324 "Requires upload file". Also, I'd like to photo to be immediately posted on the page's timeline - will it happen, or do I need to make a separate call for that?
You can switch parameter source for url, and give it a publicly reachable HTTP URL as value.
But be aware, this only works for photos not on Facebook already – feeding it the URL of a photo on Facebook will result in an error message saying that posting photos from their CDN is not possible.
I currently am able to post to a users wall however I would like the post to give a preview since what im posting is a link...
To explain myself better If i was to log into my facebook account and copy a link and paste it to my wall it displays an audio player (all the meta data is already configured, tested and working) however, using code to post this same link it doesnt show the audio player instead it only shows the link to click on. Is there a way i can make facebook display the audio player...?
Heres the code im using to post:
$fbResult = $facebook->api(
'/' . $userId . '/feed/',
'post',
array('access_token' => $access_token, 'message' => $url)
);
Thanks in advance for the help!
I’m assuming you’re posting the URL as part of your message parameter?
Do it by explicitly using the link parameter for the URL.
https://developers.facebook.com/docs/reference/api/user/#links
I have written an Application what posts Photos on a FanPage into a Specific Album long time ago.
Now I didn't used for a half year. Now I had to set up the Application again and grant the extended Permissions to the Fan Page (streamm_publish) again.
But now I've a Problem, I'm using the old REST API what now gives me the error: An unknown error ocurred with the error code 1.
Then I tried to post throught the Facebook Graph api.
I tried to make a call to the Api /pageid/albumid/photos what's not working(Unknown path components)
I tried to makea a call to /albumid_from_my_page/photos then the Photos were posted to my profile
I tried to upload it to /pageid/photos what is the same as the one above
But the code fpr the REST Api worked well, what's the problem there, and why the new Graph Api isn't working how she should?(BUG?)
To post a photo to an album, this is the code:
$post_data = array(
"message" => "My photo caption",
"source" => '#' . realpath($file)
);
$album_id = "XXXXX";
$facebook->api("/$album_id/photos", 'post', $post_data);
Now I suppose to interact with the page albums you need a page access_token added to your $post_data array, for this check this answer.
You need take ACCESS_TOKEN page...
try:
http://graph.facebook.com/me/accounts?access_token= GET THIS TOKEN USING GRAPH API... OR MAKE USING the getAccessToken()...
and will see all pages and aplications that u have, find just application for this case and COPY TOKEN... and damn!!!
It's possible to see this token thought GRAPH API EXPLORER...
regards.