Facebook 'caption' option not showing up for non-timeline Facebook - php

So I'm creating posts to the facebook user's wall using Graph API
I'm referring to the 'caption' as stated here:
http://nocturnsoft.com/devblog/?p=906
when I specified the 'caption' option, the text in the caption would appear properly for profiles that uses the timeline, but for profile that use the old style, the caption would not appear...
Am I doing something wrong here or is this how it's supposed to be....If it is how it's supposed to be, how would I display text beneath the link for the Facebook post for non timeline profiles
btw: I'm using Facebook PHP SDK

In my apps the post data array looks like this and the caption (message) is present on both new and old profiles.
/* post to fb */
$post = array(
'access_token' => $fb_access_token,
'message' => 'THIS IS YOUR CAPTION HERE',
'link' => 'LINK TO YOUR SITE OR APP HERE',
'picture' => 'URL TO IMAGE HERE',
'name' => 'APP NAME HERE',
'description' => 'AWESOME DESCRIPTION ABOUT YOUR APP GOES RIGHT HERE!'
);
$res = $facebook->api('/me/feed', 'POST', $post);
Hope this helps. If so don't forget to say so! :)

Related

Facebook development - post link with photo

I'm building an app for facebook. I need to post some link, standard code works correctly:
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => 'Mylink',
'message' => 'Posting with the PHP SDK!',
But I need to attach the photo also. It works if photo is on the link I post, but I don't want that photo to appear on that page.
Is there any way?
Simply add a parameter, picture to while making the call-
array(
'link' => 'Mylink',
'message' => 'Posting with the PHP SDK!',
'picture' => '{image-link}'

bigger images in facebook posts when posting via facebook php sdk

I have the following code to generate a facebook post for a page using graph api.
$page_info = $facebook->api("/$pageId?fields=access_token");
if (!empty($page_info['access_token'])) {
$attachment = array(
'access_token' => $page_info['access_token'],
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$status = $facebook->api("/$pageId/feed", "post", $attachment);
Posts from one of my facebook pages look like below image.
link to image - How my posts look
Then i came across some other pages, whose posts look like below image. As you can see, these preview images are large and appear above the post. When we click them, we are redirected to another website's page. So i had to assume, we are not posting this as image. Please note that i need to post my link, big thumbnail and my custom description as shown in this image.
How to achieve this?
link to image - How my posts should look like
bigger images in facebook posts when posting
Use the Open Graph to create the custom stories.

facebook wall post no image

I am adding functionality to post to a visitors Facebook wall.
I am using the following code:
$path_to_image = "http://projects.kleelof.com/boot_designer/image_interchange.php?c=" . $file_id;
$attachment = array('message' => 'this is my message',
'name' => 'The name of your company',
'caption' => "Caption of the Post",
'link' => $path_to_image,
'picture' => $path_to_image,
'description' => 'this is a description',
'access_token' => $facebook->getAccessToken()
);
//echo($path_to_image);
$result = $facebook->api('/me/feed/','post',$attachment);
The post appears on my wall, but not the image.
You can see the full process and post it makes by trying the app at: http://projects.kleelof.com/boot_designer - Then select either one of the 2 links.
take care,
lee
I think the path to the image needs to be and actual file system path, and the image will be read and uploaded along with the request for FB to process. Also, it needs to start with a # to actually upload it.

Looking for image attachment php API feeds for stream.publish

I am desperately looking for image attachment php api feeds for my facebook app.
Basically what I am trying to do is send an image attachment, along with an automatic "post to friends wall" action.
The idea behind it is that a user sends a "virtual burger" to their friends wall, with a message offering them a discount.
This is a snippet of the code that successfully sends the message, but I can't get the attachment to work.
if($_REQUEST['friend_1']!='' && $_REQUEST['friend_1']!="Start typing a friend's name") {
try {
$fql1 = "select name from user where uid=" . $_REQUEST['friend_1'];
$param1 = array(
'method' => 'fql.query',
'query' => $fql1,
'callback' => ''
);
$fqlResult1 = $facebook->api($param1);
$friend_1_name = $fqlResult1[0]['name'];
$statusUpdate = $facebook->api('/'.$_REQUEST['friend_1'].'/feed', 'post', array('link' => $fanpageURL, 'name' => 'Have a virtual Unity Burger.', 'description' => " ".$user_name." just sent you a virtual Unity Burger. If you would rather have the real thing then come add your name on the Unity list and we will give you a 20% discount on your next visit and an exclusive Unity keyring.", 'properties' => '', 'cb' => ''));
} catch (FacebookApiException $e) {
//echo "Notification not send to user ".$fqlResult1[0]['name']."<br>";
I think there are two ways to attach an image to a wall post.
The first one is to define the meta og:image in the target page and post the link to the friends wall. Facebook will query the target and grab the Open Graph info displaying it in the wall. You can test this with the Facebook Debugger.
The meta property should look like this:
<meta property="og:image" content="http://url.to/image" />
You can also define other Open Graph properties like title, description, etc.
The second way to attach the image to the post is to include the picture parameter in the Graph API call. In your code you only define some parameters (link, name, description...) but you can also send picture, caption, message...
So your API call could be like this:
$params = array( 'access_token' => '',
'message' => '',
'link' => '',
'picture' => '',
'name' => '',
'caption' => '',
'description' => ''
);
$wallPost = $facebook->api('/'.$to.'/feed', 'post', $params);

How can I post to the wall of a Facebook Fan Page using PHP and Open Graph API

Sample code is appreciated, I can't seem to find any simple examples of this online.
Using the new Facebook PHP-SDK, it's very easy to accomplish this.
Requirements:
Extended Permissions, depending on your needs
Page ID
Now as I said, depending on your requirements you may need offline_access, manage_pages, but for now this is the simplest straight forward way of doing this:
After downloading the PHP SDK, and in the example.php file:
Acquire the publish_stream permission:
<fb:login-button perms="publish_stream"></fb:login-button>
After successful authentication, you post to the page wall the same way you do it for normal user profile (and with the same options too, message, picture, link, name, caption, description, source):
$page_id = '123456789';
$feed_array = array(
'message' => "Hello world!"
);
$page_post = $facebook->api("/$page_id/feed","post",$feed_array);
Result:
Please note that this approach requires you being an administrator of the page.
in this change the /me/feed/ to your page id, I did't try....Just check
$attachment = array('message' => 'some meesgae',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'mylink.com',
'description' => 'this is a description',
'actions' => array(array('name' => 'Get Search', 'link' => 'google.com')) );
$result = $facebook->api('/me/feed?access_token='.$access_token, 'post', $attachment);

Categories