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.
Related
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' => ''));
When we post a feed on Facebook using Graph API, a parameter is passed called "Action" in which we need to pass an array of actions which contains name of action and link.
$feed=array(
'message' => "Trial fb post",
'name' => "trial",
'caption' => "Trial caption",
'actions' => array(
array(
'name' => 'Give it a try',
'link' => 'http://www.blinkpot.com/'
)
)
);
I saw some posts having like this page option by which users can like the respective page.
How can I attach that action with my post.
There are a lot of questions on SO about this, but not exactly what I am looking for.
In my case, users can log in through Facebook/Twitter/other. And they can upload an image.
Once they upload an image, two things will happen. The FB user's status is updated with an attachment to the link. And on the FB App's wall, a status update is also posted but by the application itself and not by the user. I am having trouble with this last part. So the user does not have to be logged in through Facebook for this latter to occur.
My code:
$facebook = new Facebook($config);
$attachment = array(
'message' => 'A user just posted a new item',
'name' => $tag,
'caption' => $desc,
'link' => WEBURL,
'description' => '',
'picture' => $img,
'actions' => array(array('name' => 'Go to item',
'link' => WEBURL))
);
$facebook->api('/'.PAGEID.'/feed', 'POST', $attachment);
An application's wall behaves exactly like a page's wall or a user's wall. Lookup the documentation for those.
How do I set the height of the swf file posted to facebook feed using the PHP API.
Here is my code. It is working fine but I cant find a parameter to set the height.It height is automatically set to 259px. I tried the extended_height parameter also but no luck. Do I have to use the REST API?
$options = array(
'access_token' => $facebook->getAccessToken(),
'link' => 'http://www.example.com/',
'name' => 'Test App',
'caption' => "Created using my test app",
'picture' => $apppath.'Icon.jpg',
'source' => $apppath.'main.swf',
'description' => "Description field",
'actions' => array( 'name' => 'Click me', 'link' => 'http://www.google.com' )
);
$wallPost = $facebook->api('/'.$friendid.'/feed', 'post', $options);
Anybody got a solution ?
Have you checked this ? https://developers.facebook.com/docs/guides/attachments/
it shows how attachments are made. Plus if you want you can even use open graph tags in your page to show the media once your page is shared via FB
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..