Post SWF in user timeline - facebook

I have a problem in my iframe facebook application, is a music app where the users can post music in a music player, then problem is that when the user share the SWF into the timeline wall the players doesn't appear, it only show the URL to the music file.
I added the server IPs list in the Whitelist app configuration, how can I solve it? :(
Here the code:
try {
$actions = json_encode(array(array('text'=>facebook_app_post_ok_in_my_profile, 'href'=>'http://apps.facebook.com/fbapp/post_check.php? where=me&song='.$selected_value.'')));
$param = array(
'method' => 'stream.publish',
'callback' => '',
'name' => facebook_app_post_ok_feed_name,
'href' => 'http://www.site.com',
'description' => facebook_app_post_ok_description,
'message' => $message_feed,
'attachment' => '{"media": [{
"type": "mp3",
"src": "'.$real_source.'",
"title": "'.$song_title.'",
"artist": "'.$song_artist.'",
"album": "'.$song_album.'"
}]}
','action_links' => $actions,
'target_id' => $user_id,
'privacy' => ''
);
$facebook->api($param);
}
Thanks!

You'll want to follow the instructions in this tutorial. I know it's called Feed Gaming and that's nothing to do with what you're trying to achieve, but the basic premise is the same. You want an interactive swf that the user can open in their News Feed.
Once you have you OG markup in place on the end URL, FB will pick all that up and render the swf.

Related

Facebooks Link preview

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' => ''));

PHP SDK: Post to FB application's wall as the app itself

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 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, ...

Send notification or post on wall

i have been going crazy and cant figure out how to make a script for my application that would allow the user to select a friend and send them a notification or post on their wall from my application.
I just need to notify their friend that they have been challenged to play a flash games, just a simple text with a link, i dont need anything fancy :D
Here is what i tried and it doesnt work :( no idea why.
$message = 'Watch this video!';
$attachment = array( 'name' => 'ninja cat', 'href' => 'http://www.youtube.com/watch?v=muLIPWjks_M', 'caption' => '{*actor*} uploaded a video to www.youtube.com', 'description' => 'a sneaky cat', 'properties' => array('category' => array( 'text' => 'pets', 'href' => 'http://www.youtube.com/browse?s=mp&t=t&c=15'), 'ratings' => '5 stars'), 'media' => array(array('type' => 'flash', 'swfsrc' => 'http://www.youtube.com/v/fzzjgBAaWZw&hl=en&fs=1', 'imgsrc' => 'http://img.youtube.com/vi/muLIPWjks_M/default.jpg?h=100&w=200&sigh=__wsYqEz4uZUOvBIb8g-wljxpfc3Q=', 'width' => '100', 'height' => '80', 'expanded_width' => '160', 'expanded_height' => '120')));
$action_links = array( array('text' => 'Upload a video', 'href' => 'http://www.youtube.com/my_videos_upload'));
$target_id = $user;
$facebook->api_client->stream_publish($message, $attachment, $action_links, $target_id);
UPDATE:
appinclude.php
$facebook->redirect('https://graph.facebook.com/oauth/authorize?client_id=132611566776827&redirect_uri=https://apps.facebook.com/gamesorbiter/&scope=publish_stream');
Error i get:
{
"error": {
"type": "OAuthException",
"message": "Invalid redirect_uri: The Facebook Connect cross-domain receiver URL (https://apps.facebook.com/gamesorbiter/) must be in the same domain or be in a subdomain of an application's base domain (gamesorbiter.com). You can configure the base domain in the application's settings."
}
}
Without the extra "s"(http) i get this error:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
Please if you could post an example.
Also do i need extended permission to do that or if the user sends the message i dont need that ?
Thank You
Also do i need extended permission to
do that or if the user sends the
message i dont that ?
Yes, you need the offline_access and publish_stream extended permission from the users.
Update:
In your appinclude.php file, put code like this:
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();
$facebook->redirect('https://graph.facebook.com/oauth/authorize?
client_id=[YOUR APP ID]&
redirect_uri=[YOUR APP URL]&
scope=publish_stream, offline_access');
Replace [YOUR APP ID] with application id that you can see from application settings where you created the site in Facebook Developers section. Also replace the [YOUR APP URL] with your app url.

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.