Facebook post image not displaying - php

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

Related

Facebook upload fan page in PHP not working anymore

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.

Publish video on facebook page wall using graph api with no share button

I tried earlier to publish video on Facebook page using Graph API without share button or link
Old code:
$data = array(
'name' => 'name',
'caption' => 'caption,
'link' => 'http://link.com',
'description' => 'description,
'picture' => '[picture url]',
'source' => '[video source]'
);
$result = $facebook->api('https://graph.facebook.com/[page_id]/feed?access_token=[page access token]',$data);
The above publication is treated earlier as post with video in it, but now its just treated as a link and the source video is not played in it. Same way we have 'share' link too.
Currently i required the publication to be treated as video + no share link.
I am unable to give empty "actions", whereas if i give "actions", the post has video played inline.
I want to know, how to publish video on page wall with no share button?

Facebook Graph Api posting on friends wall

I'm having a problem when trying to post a link to a friends wall using the Facebook graph from my application.
I am currently using the Facebook SDK for PHP, I have no problems posting to the wall of the user that's logged in but cannot post to friends of the logged in user.
I have requested the extended permission "publish_stream" and here is the code am I using:
$args = array('message' => $message,
'link' => 'google.com',
'name' => 'Test!',
'caption' => 'Please click on the link',
'description' => 'description');
$result = $facebook->api("/$friendId/feed", 'POST', $args );
$friendId has the facebook id of the friend of the logged in user, any help would be much appreciated.
A quick scan of the FB API reference shows that you can set the to key value pair in this operation to
mention or target a user in this post

programmatically login to facebook and post to page (wall)

I have a website, and I need it to post status updates to a Facebook Page from time to time.
Using my personal Facebook account, I created an App, and a Page. So far, I've been able to programmatically post to my Page's Wall, by adding this code to my website:
include_once "lib/facebook/src/facebook.php";
$facebook = new Facebook(array('appId' => 'APP_ID_HERE', 'secret' => 'APP_SECRET_HERE'));
if($facebook->getUser()) {
try {
$ret_obj = $facebook->api('/FACEBOOK_PAGE_ID_HERE/feed', 'POST', array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!',
'access_token' => 'FACEBOOK_PAGE_ACCESS_TOKEN_HERE'
));
echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';
} catch(FacebookApiException $e) {
// user logged out (has user_id, but invalid access token)
$login_url = $facebook->getLoginUrl(array('scope' => 'publish_stream'));
echo 'Please login.';
}
echo '<br />logout';
} else {
$login_url = $facebook->getLoginUrl(array('scope' => 'publish_stream'));
echo 'Please login.';
}
So I just open my website, click "Please login", login as myself. Once I'm logged it, it will now be able to post the status update to the Facebook Page.
Obviously, the problem here is that I need to be logged in for it to be able to post. If other users will try to login with their user accounts, my website cannot post status updates to the Facebook Page because I am the only Admin for the app/Page.
My question is, is there a way for me to programmatically log myself into Facebook so I can do these status updates to my Page automatically?
Sorry, total noob here to Facebook development.
Seems like you need to update status while you are offline from facebook. To do this you need to get the offline access permission of the app user and you need to have a "infinite" token for facebook app to access the APIs, so that your program can update anytime you want with out logging into facebook.
You may get something you want here
http://developers.facebook.com/docs/authentication/
I'm a little late to the party here, but I thought I'd post my gist example for how to do something very similar. I added some functionality to fbconsole to make it easy to programmatically login with fbconsole.automatically_authenticate to make it much easier to access this information in a systematic way. This addition has not yet been incorporated into the master branch of fbconsole (it was just posted this morning), but it is available here in the meantime for those that are interested.
This is what I use to do,
// = SET WALL DATA HERE ===============
$attachment = array(
'access_token' => 'My Access token here',
'message' => '',
'name' => 'My Wall Post Header/Title Here',
'caption' => 'Small caption here',
'link' => 'http://www.mywebsite.org',
'description' => 'Wall Post Details Here',
'picture' => "http://www.mywebsite.org/images/logo.gif",
);
// =POST ON FACEBOOK WALL ==========================
$this->facebook->api('/me/feed', 'POST', $attachment);
, $attachment);
So include your Facebook API, Get your Facebook Access token, SET data for your wall post and call for facebook api with me/feed method.
This will make a wall post on your wall without asking for login.
make sure you are using correct Access Token.

Post image to Facebook fan page with PHP SDK

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.

Categories