Please suggest how to post some text which is entered by an end user after clicking on a button. I searched in social plugins of Facebook. I found share plugin but it is sharing only links but not the text. How can I post the text to Facebook? In my application, I'm using normal "textarea" to enter the text/status and I'm using a submit button to post it. I want to post the entered text to my timeline in Facebook. Is there any plugin available for this? Please suggest.
Thanks,
Dinakar.
Using Javascript SDK
<script>
function share()
{
var obj = {
method: "feed",
link: "Facebook page hyperlink",
picture: "Picture hyperlink",
name: "Title",
caption: "A short caption right below the title",
description: "Description"
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
For More info: http://developers.facebook.com/docs/reference/dialogs/
Related
When I post images using FB.ui feed it works fine but the images are links son when you click on them you cannot see a bigger version of the image.
I read that you can use:
FB.api('/me/photos?access_token=’…
But I need the dialog so the user can see the photo and add a message in FB “environment or context”.
This should be simple, no?
This is my current code:
var obj = {
method: 'feed',
link: url_base,
picture: up_img_final_url,
name: FBname,
caption: FBcap,
description: FBdesc,
};
FB.ui(obj, function(response){
if(response)console.log('Post');
else console.log('Cancel');
});
So I've been trying to implement a Fb method feed so that people can share songs from my website. But it doesn't work.
It pops up a loading gif in the dialogue and thats it. No error nothing. I've wasted a lot of time trying to figure this out but haven't been able to.
Here's the code,
share_obj = { method: 'feed',
link: "", redirect_uri: "",
picture: ",
name: "",
caption:"" ,
description: ""
}; FB.ui({method: "permissions.request", "perms": 'publish_stream'},
callBack);
function callBack(response) { if(response["perms"]=="publish_stream") { var obj = share_obj; FB.ui(obj,callback_share); } } function callback_share(response) { }
Does it have something to do with Facebook app migrations or app permissions?
So turns out, there s no need to ask for user permissions when invoking the Fb.ui method.
Permissions are only required when you intend to publish stories via the graph API.
I have been searching for facebook publishing without showing Dialogue.
While reading Facebook developers doc, there are several things which seems to answer the question but after using them, I concluded those are not for this functionality.
Display Modes: They are different type of display mode for dialogues, but there is no way to define if I don't want to show the dialogue.
Explicit Sharing: This seems to be most close. But there is no way to use it in JS SDK. And the parameter mentioned there, I tried in JS but no resolution.
Then here what came to be most successful for me, to use
methode: '/me/feed'
But the problem is, it says:
[User] shared a link
Which I don't want. I want a normal publishing, but without any dialogue to be displayed.
Code I am using for simple publishing is below:
function publishNewsFeed(picURL, name, caption, description)
{
var obj =
{
method: 'feed',
link: fbAppURL,
picture: picURL,
name: name,
caption: caption,
description: description
};
function callback(response)
{
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
Any help will be appreciated.
Thanks
-WI
Display Modes: They are different type of display mode for dialogues, but there is no way to define if I don't want to show the dialogue.
That would be nonsense – if you don’t want to use a dialog, then don’t use a dialog.
But if you want to use a dialog, then it has to be “shown” in some way – otherwise it would not be a dialog.
But the problem is, it says [User] shared a link Which I don't want.
That is current “bug” – if you supply action links with your post, it will show up normal.
https://developers.facebook.com/bugs/485696594791863
Try this:
function jesseSays(){
var body = 'Yeah science Mr. White!!';
FB.api('/me/feed', 'post', {
message: body,
link: 'http://www.neoapps.com.br',
picture: 'http://www.neoapps.com.br/assets/img/logo-big.png'
}, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}
I have a feed post JS as follows.
var feedObj = {
method: 'feed',
link: link,
picture: imagelink,
name: name,
caption: caption,
description: description,
redirect_uri: "http://"+(window.location.host)+"/",
next:null,
app_id: appid,
actions: [
{ name: text, link: link }
]
};
function callback(response) {
if(response){
}
}
facebook.ui(feedObj, callback);
How do I make sure the feed dialog that clicked to post closes automatically?
I have noticed that the callback is not fired always and this attempt below does not work always
function callback(response) {
if(response){
facebook.Dialog.remove(facebook.Dialog._active);
}
}
I have got a simple trick to close this dialog box. It is not a good way to do this type of work but it just worked fine for me.
Firstly you have to create a page on your server (e.g. closewindow.aspx) and paste this code in your page's body part.
<script src="js/jquery.js" type="text/javascript"></script>
<script>
$().ready(function() { window.close(); });
</script>
Than set redirect_uri parameter property to this page, like :
redirect_uri=http://www.yousitename.com/closewindow.aspx
Now this time in dialog box, this page will be called as redirecturl and the dialog will be closed automatically on page load.
I know this may be tricky but you know how it feels when got this working.
According to the documentation, next is not a parameter.
I understood that with redirect_uri callback is not being called.
Since redirect_uri is supported by most sdks you need not use it.
DEMO
Hope this helps
Can someone please explain to me how can I have a download link appear when a user presses the share button on a feed dialog box? I'm using the following code: (with my own information of course)
Post to Feed
<script>
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
I have no clue on how to do is: what code do I need so that when a user clicks "share" a download box appears? But if they click cancel a message pops up telling them they need to share first? I have posted a similar question before and I got an answer saying I need to use some sort of JavaScript but the problem is I don't know how or what to write? Can someone please show and explain the sort of JavaScript I need to me because I don't know how to use JavaScript one bit.
Thanks in advance for any answers/help!!
The callback function is executed when the user completes the feed post dialog, with either the "share" or "cancel" button. You can test for a "post_id" to see which action the user took. Then either show the download box or display an alert (or perhaps a more user-friendly message format).
Add a hidden download box element to your page with an id of "download_box":
<div id="download_box" style="display: none;">
Download Box (whatever that means) goes here
</div>
And replace your current "callback" function:
function callback(response) {
if (response && response.post_id) {
document.getElementById('download_box').style.display = 'block';
} else {
alert('You must share your post before you can download.');
}
}