using facebook stream publish - facebook

I want to publish a URL as an attachment to a friends wall:
var attachment={'name':'favor','href':'http://128.196.239.71/movie.php?mid=<?php echo $_GET['mid']; ?>'};
Facebook.streamPublish('',attachment,null,friends[i],comment,callback);
Doing the above gives me a Facebook undefined, what should I do to remedy this?
Do I need to set a special permission in order to do this to the sender of this message?

You do need the stream.publish permission in order to use the stream.publish method or the equivalent graph API call.
You can check that the user has already granted this permission with something like this:
FB.getLoginStatus(function(response) { if (response.perms) { /* check perms */ } })
You can request the permission with something like this:
FB.login(function(response) { /* check perms */ }, {scope: 'publish_stream'})
Then in the response you can check to see if it was actually granted, then you should be able to do stream publish calls.
However, I don't recognize the format of your call "Facebook.streamPublish". I think the new API requires you to do a call more like
FB.api({method: 'stream.publish', message: 'hello'}, function(response) {})
Alternatively to all this, you can use the dialogs API to create a post and show it to the user, and have them approve it or disapprove it. This does not require the stream.publish permission. Something like this (the example given in the FB.ui API docs):
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
At the rate Facebook changes, I hope some of this information is still accurate by the time you read it (or even accurate to begin with).

Related

Facebook jssdk customizes the shared feed interface. Why don't the parameters of picture work?

According to the official Facebook document,url:https://developers.facebook.com/docs/sharing/reference/feed-dialog
But the parameters in the "Deprecated Parameters" column below do not work.
Is the interface function turned off?
I hope someone can help me. Thank you.
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
redirect_uri:location.href,
link: location.href,
picture: 'https://pic3.zhimg.com/80/37e17fa3d5d60f9e8bcba3bdc7e7dc06_hd.jpg',
caption: 'Reference Documentation',
description: 'tDialogs provide a simple.',
message: 'tFacebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
console.log(response)
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
But the parameters in the "Deprecated Parameters" column below do not work.
That is why they are in the deprecated section (deprecated means "old" or "gone"), they don´t work anymore since a very long time. You have to provide that data with Open Graph tags in the source of the shared URLs.
More information about Open Graph tags: https://developers.facebook.com/docs/sharing/webmasters/#markup

FB.UI using imaging staging

I have a standard file-upload form, which I want to use to collect a user's image and than upload to Facebook.
If I post the upload form to the FB 'staging' url, I get the encoded staging reference - but when I try to launch a FB.UI() feed dialog, supplying the staging token as a "picture" parameter it fails?
Is the staging URL strictly for use in creating a graph object w/o using the dialog? And if I want do use the dialog do I have to upload the image somewhere else and than reference it ?
Here's my example:
$('#picture_upload').submit(function(e){
e.preventDefault();
$(this).attr('action',$(this).attr('action')+'?access_token='+accessToken);
$(this).ajaxSubmit({
success: function(response){
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
picture: response.uri,
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
} //call function after success
});
});
The response contains something like:
{"uri":"fbstaging://graph.facebook.com/staging_resources/MDAxMDE1MTU3NjIyNzExNzYwNA=="}
Which is obviously invalid as a picture parameter in the FB.UI function

Facebook Direct Messages for Mobile Devices Options

Now that Facebook rolled out their new policy in February 2013 where, among other changes, apps cannot post on friend's wall; and Send Dialog is not supported for Mobile Devices.
What options do we have to post on a user's friend wall (on behave of the user already authenticated with an app) using mobile devices?
You can use feed dialog or redirect the user to a mobile friendly url by adding display=touch and *to=FRIENDS_ID* and show a dialog box.
To display a mobile-friendly Feed Dialog, redirect the user to the following URL:
http://www.facebook.com/dialog/feed?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&to=FRIENDS_ID&display=touch
Using feed dialog and javascript api
function postToFeed(kompis) {
// calling the API ...
var obj = {
method: 'feed',
redirect_uri: 'http://url.nu',
link: 'http://www.url.se',
picture: 'http://url/tfc.gif',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.',
display:'touch',
to:kompis
};
function callback(response) {
if (response && response.post_id) {
alert('Post was published.');
document.getElementById('status').innerHTML = "Post ID: " + response['post_id'];
} else {
alert('Post was not published.');
}
}
FB.ui(obj, callback);
}
ps: when I try it in firefox I set my User Agent to "iphone" otherwise it would'nt work!
open facebook app.first open your account.open yuor profile.edit your number.ok the option 'get notifications by sms'.save the options.

Facebook API feed dialog - prevent unnecessary click

hi,
Using Facebook's API it's possible to prompt a user to post to his/her wall using the feed dialog. However, using the javascript SDK, this requires two clicks: one on the button which brings up the dialog, the other on the "Share" button within the dialog.
Is it possible to get rid of one of these clicks? I thought of two approaches:
Embedding the dialog within an iframe, as Facebook provides a URL for a full page dialog. That will require the user to click only on the "Share" button. Apparently Facebook blocks that option.
Using an access token and display=iframe, but I want to avoid the user having to authorize my application.
Any ideas?
i would suggest you to use fb.api instead.
function PostToMyWall(){
FB.login(function(response)
{
if (response.authResponse)
{
//Post to my wall
FB.api('/me/feed', 'post', {
message: lnk,link: lnk
},
function(response) {
if (!response || response.error) {
// //alert('Error occured');
} else {
// //alert("Successfully Posted to My Wall!");
}
});}else
{
alert('Not logged in');
}}, { scope : 'publish_stream' });
}
My application got a similar function, check it out at www.wootube.woolei.com - "Post to WooTube Page and Group"
or popup when the page using jquery
$(document).ready(function() { FB.ui({method: 'feed',
name: mdtxt,
link: lnk,
picture: hackImageUrl(img,fld),
caption: '<?php echo $clickme; ?>',
description: '<?php echo $app_desc; ?>'
},
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert("Successfully Posted to Group");
}
});});

Facebook application, dialogue to publish on user's wall, using Javascript API, pop-up blocked in browsers

I am using JS-API to generate a dialogue which asks for permission to publish the status message generated by my Application. Given below is the screenshot of what I am talking about:
Here is the code:
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
I use the sample JS code as told in the documentation and it works well if pop-ups are not blocked in the browser settings. but without status message being displayed there's no utility of the app!
Please help; I'm stuck at the last stage.
I don't see why it's bothering you. If the user is blocking FACEBOOK pop-up then it's his loss!
Anyway, if you really need to handle all cases, then you can choose a different way. Have a read of the Feed Dialog.
What you could do is when you are done from the previous step you redirect your page to the Facebook feed method so it'll open as a page:
http://www.facebook.com/dialog/feed?
app_id=123050457758183&
link=http://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&
message=Facebook%20Dialogs%20are%20so%20easy!&
redirect_uri=http://www.example.com/response
The important part to change here is the app_id and redirect_uri, so your code would look like:
...
previous code
...
inside previous code success response
...
var url = "http://www.facebook.com/dialog/feed?" +
"app_id=" + YOUR_APP_ID + "&" +
"link=http://developers.facebook.com/docs/reference/dialogs/&" +
"picture=http://fbrell.com/f8.jpg&" +
"name=Facebook%20Dialogs&" +
"caption=Reference%20Documentation&" +
"description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&" +
"message=Facebook%20Dialogs%20are%20so%20easy!&" +
"redirect_uri=" + YOUR_REDIRECT_URI;
top.location.href = url;
Your code is fine. It brings up the Feed Dialog for me. Your problem is somewhere else. Did you add the <div id="fb-root"></div>? Make sure it is at the top of the page just after the <body> tag.
Also make sure you are loading the FB Javascript SDK properly:
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
Use this code
you have forget to add display property
FB.ui(
{
method: 'feed',
display: 'popup',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);