Facebooks Link preview - facebook

I've searched and searched and searched and cannot find a way for a person to post a link on a page from an app (As the page owner, of course), and have a link preview. It just posts the link instead of a preview like it would if you were posting via facebook. I would like to know if there is a way to override the link preview like this:
$x = $facebook->api('/'.$_POST["id"].'/link', 'post', array('message'=> urldecode($_POST["message"]), 'access_token' => $_POST["auth"], 'cb' => '', 'picture' => 'url to pic','description'=>'blah blah'));
Please help, don't really know what else to do..

Consider using a link shorter service that allows customization of link preview. With linkfork.co you can customize the image, title, and description.

I did a lot of testing and came up with my answer:
$x = $facebook->api('/'.$_POST["id"].'/links', 'post', array('link' => $url,'caption' => $data['description'],'name' => $data['title'],'picture' => $data['thumbnail_url'],'url' => $url, 'message'=> urldecode($_POST["message"]), 'access_token' => $_POST["auth"], 'cb' => ''));

Related

Cannot post link to fb via app

If I post a link, it shows up ad posted by me as user. If I post a message, it shows up as posted by the page itself. Why is that? I need the link to show up as posted by the page, not me. The page is mine.
$attachment = array(
'access_token' => 'page-token-here',
'image' => $code->image_urls,
'name' => $code->title,
'link' => $short_url,
);
$page_id="page-id-here";
$res = $facebook->api('/'.$page_id.'/feed','POST',$attachment);

post on Facebook page big photo

I have read quite a few posts about posting photos on FB (fan)page but none really answer my question.
I am using a correct call to the FB SDK to post on my page as you see the last post where there is a thumbnail photo and a few pieces of text including a link.
$attachment = array('access_token' => $FB_Token, 'message' => $FB_AppMsg,'name' => $FB_AppTitle,'link' => $FB_AppURL,'description' => $FB_AppResume),'picture'=> $FB_AppImage,
'actions' => json_encode(array('name' => $FB_AppActionName,'link' => $FB_AppActionLink)));
$status = $facebook->api("/".$FB_PageName."/feed", "POST", $attachment);
Instead of a thumbnail image, I want an image of the width of 1 or 2 column (as you will see down the timeline), and a text message that can include a link to my blog on my website.
How can I achieve this easily ?

How to publish a wall post with 2 pictures

I'm creating a small app in which people compare diferent pictures of him and his friends.
The app is verry simple and I have no problem with it. The problem comes when users try to publish in their walls. I want the posts to be something like:
I know that by doing something like:
$parameters = array('message' => 'this is my message',
'name' => 'Name of the app',
'caption' => "Caption of the Post",
'link' => 'http://www.link.com',
'description' => 'description',
'picture' => 'http://mysite.com/pic.gif');
$result = $facebook->api('/user_id/feed/', 'post', $parameters );
You can post on a wall, but that limits the app to one picture only and I want the users to be able to post two diferent picures.
Is there a way to publish a post like the one in the image?
EDIT:
Added a picture that might explain what I want in a better way.
Without getting too deep into the Facebook API (since I've never seen a FB app post two photos, I'm guessing it's not possible - most of the apps I see would be as spammy as allowed...), I'd probably start by just compositing the two images (and doing any overlays I wanted to do) at the server side dynamically using something like PHP and the ImageMagick classes.
Then, just feed Facebook the URL to the PHP script that does the compositing, e.g.
$parameters = array('message' => 'this is my message',
'name' => 'Name of the app',
'caption' => "Caption of the Post",
'link' => 'http://www.link.com',
'description' => 'description',
'picture' => 'http://mysite.com/pic.php?pic1_id=1234&pic2_id=2345&favorite=pic1');
$result = $facebook->api('/user_id/feed/', 'post', $parameters );
Of course, I don't know what sort of dimensions Facebook will take for a picture to be posted with a wall post - it might not be wide enough for this to work. I'd try it, though...
Facebook did away with multiple pictures in a post a while ago. When you were able to do it, people were creating "banners" that consisted of multiple pictures side by side. Now only 1 pictured is displayed for any wall post. You can post more pictures, but they won't be sure by default. Facebook will add a "more" link, although they may have done away with that also.
At least in Javascript when using Facebook.streamPublish, as second argument you can give an attachment object that may contain an array of media. Here are the relevant pieces from my app Japan Name:
var media = [];
for (var i = 1; i < syls.length; i++) {
media.push({
'type' : 'image',
'src' : 'http://youarecu.appspot.com/chars/' + syls[i] + '.png',
'href' : streamhref
});
}
...
var attachment = {
'href':'http://apps.facebook.com/youarecute/?from_wall=true&postid=f'+uid+'{{postid}}',
'name':linkedtxt,
'description':txt,
'media':media
};
...
Facebook.streamPublish("", attachment, ...

Posting Attachment Facebook Graph API

Right now I'm trying to figure out how to post an attachment using facebooks graph api.
Right now I'm using
$attachment = array(
'message' => $_POST['tt'],
'text' => 'Download',
'name' => 'name',
'href' => 'http://www.url.com',
'description' => ' description!',
'media' => array(array(
'type' => 'mp3',
'src' => $url,
'href' => 'http://www.url.com/',
'title' => $title,
'artist'=> 'artist',
'album'=> 'the album')));
$statusUpdate = $facebook->api('/me/feed', 'post', $attachment);
Problem is it's only posting the message, nothing else, no attachment or anything.
Does anyone have any idea why?
Thanks
Attachments aren't yet supported by the Graph API.
Per the documentation
Arguments message, picture, link,
name, caption, description, source
See my answer in your other question for a workaround.
You have to use the old php SDK until graph supports attachments... Graph only supports photoupload.
Im mixing Graph and old SDK without problems..

How to include html in stream.Publish

I'm using the old Rest API (and old Javascript SDK) to develop an iframe application inside facebook.
However I would like to have the wall posts (calling stream.Publish) to include new lines and having people's names with links to their profiles. However every time I include html content, FB strips it.. but I know it can be done, because some apps do it, for example:
http://img.skitch.com/20100702-jhqradpi3td4d53sdb3qin92sb.png
Cheers,
Ze
You cannot have arbitrary HTML in a wall post. If it looks like HTML, Facebook will strip it. The only other alteration Facebook will do I believe is convert text that looks like links into links (so if you have http://www.google.com somewhere in the message, Facebook will automatically turn it into a link).
However Facebook does provide basic facilities for including basic things like a picture, caption, description, link, etc through stream.publish by passing in additional parameters. This is an example for including a few of these things from Facebook's documentation (http://wiki.developers.facebook.com/index.php/Stream.publish):
$message = 'Check out this cute pic.';
$attachment = array(
'name' => 'i\'m bursting with joy',
'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/',
'caption' => '{*actor*} rated the lolcat 5 stars',
'description' => 'a funny looking cat',
'properties' => array('category' => array(
'text' => 'humor',
'href' => 'http://www.icanhascheezburger.com/category/humor'),
'ratings' => '5 stars'),
'media' => array(array('type' => 'image',
'src' => 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg',
'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/')),
'latitude' => '41.4', //Let's add some custom metadata in the form of key/value pairs
'longitude' => '2.19');
$action_links = array(
array('text' => 'Recaption this',
'href' => 'http://mine.icanhascheezburger.com/default.aspx?tiid=1192742&recap=1#step2'));
$attachment = json_encode($attachment);
$action_links = json_encode($action_links);
$facebook->api_client->stream_publish($message, $attachment, $action_links);
Check this out for more info on what attachments you can include.