I'm using the following code to upload photos to Facebook fan page as the page (not as a user):
$ret_obj = $facebook->api ( '/'.$fanpageid.'/photos' , 'POST' , array(
'source' => '#' . $filename,
'message' => $message,
'link'=>$link,
'access_token'=>$accesstoken
));
This code was working until June 11th, 12 AM. Did Facebook change the way it works?
I have the fan page access token, and everything was working fine. How do I make it work?
found the solution myself, an alternative way is working instead of
'source' => '#' . $filename,
using
'url' => $fullpathfilename,
is working, weird that facebook doesnt document those important changes.
Related
Looks like a lot of the tutorials online are outdated including anything in stack-overflow and they don't work. Plus facebooks SDK documentation doesn't say anything about it. How would I get a users profile picture ?
What I've seen so far and it doesn't work.
https://graph.facebook.com/Facebook_user_id/picture
Figured it out, to get it via the api you do this:
$config = array(
'redirect' => false,
'height' => 186,
'width' => 186,
'type' => 'normal',
'is_silhouette' => 0
);
$fb_image = $this->facebook->api('/me/picture', $config);
//print_r($fb_image);
echo "<img src='" . $fb_image['data']['url'] . "'>";
Reference: https://developers.facebook.com/docs/graph-api/reference/user/picture/
click on php-sdk
If you want to download a picture to the server, use CURL (but be sure that you allow redirection) or file_get_contents with URL you specified. It works well. It should also work with Facebook PHP SDK, too. [documentation]
If you want to show a picture to the client, just put URL you specified to an image tag
Code:
<img src="https://graph.facebook.com/4/picture/" />
Result:
Try:
http://graph.facebook.com/id/picture?type={small,large,normal,square}
example http://graph.facebook.com/subhanker.chourasia/picture?type=normal
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 want make a wall post on friend wall using facebook graph api.
Everything works good but image is displaying.
Here is my code.
$attachment = array(
'message' => $d['giftmsg'],
'name' => 'You have received a gift voucher for ' . $dd['title'] . '!' . '',
'link' => $plink,
'description' => " Login to the Tippll facebook app to claim you gift card. Your friends can click on the like above to top up this gift even further!",
'picture' => $img_url,
'actions' => array('name' => 'Top-Up This Gift', 'link' => $plink)
);
$post = $facebook->api('/' . $_POST['friend_id'] . '/feed', 'POST', $attachment);
Here $img_url contains the valid url and it shows image when i enter this url to browser address bar. But facebook is not fetching it to my post.
I tried image from other servers and it works image hosted on other server but not in my server.
I m using htaccess to redirect www to non www.
Please suggest me the solution.
Thanx in advance,
There could be 2 possibly reasons:
Your image cannot be accessed by facebook as facebook first get's your image and stores it on their cloud.
Your host is banned by Facebook and no longer accepts images from your URL's
i'm using this code to post to my application wall
$attachment = array('message' => 'xxxxxxxxxxxxxxxx...',
'name' => 'xxxxxxxxxxxxxxxxxxx',
'caption' => 'xxxxxxxxxxxxxxxxxx',
'link' => 'xxxxxxxxxxxxxxxxxx',
'description' => 'xxxxxxxxxxxxxxxxxx',
'picture' => 'xxxxxxxxxxxxxxxxxx',
'actions' => array(array('name' => 'Download!',
'link' => 'xxxxxxxxxxxxxxxxxx'))
);
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
when i post to my application wall manually the post is appearing on the application users wall with the share action
but when i use the above code it only appear on the app wall with like and comment actions only.
why?
and how to add the share action to the actions array?
i didn't find any answer online, but i just found the solution to my problem by chance
i removed the action parameter from the attachment.
but if there is a link parameter in the attachment the share action won't appear so you will have to give up the link parameter.
the proper names for the action link is:
array( array('text' => 'Download!', 'href' => 'xxxxxxxxxxxxxxx'));
Keep in mind that you can't use action links in the graph api (yet). so this functionality is limited to the REST api.
Let me know if this helps
http://facebookanswers.co.uk/?p=270
This article explains it. The key is this:
'actions' => array('name'=>'Sweet FA','link'=>'http://www.facebookanswers.co.uk'),
This is fine for adding one action. However, I'm not sure how to add two.
Hi the solution is here
instead of
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
use
$result = $facebook->api('/2222222222222/links/','post',$attachment);
i'm still facing one little problem with the picture not showing after this change, if i come to a solution to it I'll come back here and post it.
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.