The Fb.ui feed method open a new small window for posting a new feed. I want it to open postiing request in the same window and after posting redirect to same(prev) window.
Any one??
Edited:
FB.init({appId: "1234567890", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
display: 'touch',
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);
}
#Nitzan Tomer
Yes this opens the dialogue box, but this thing doesn't work in iPhones/iPads. If works then i dont want to open a new window/tab for it, but want the whole process(auth and posting) in the same window where the user is/were.
You can use redirect url method given on Facebook Developer website.
https://www.facebook.com/dialog/feed?
app_id=123050457758183&
link=https://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Using%20Dialogs%20to%20interact%20with%20users.&
redirect_uri=http://www.example.com/response
Related
I am trying to share image from FB app, using send dialog like I am doing for past few years.
var obj = {
method: 'feed',
link: 'https://www.facebook.com/pages/TESTPAGE?sk=app_XXXXXXXXXXXXXX&app_data=share|10',
caption: '',
name: 'Title for share',
description: 'description fort share',
picture: IMG_URL
};
I have provide 2 screenshots
when I click on share button inside of app
what I keep getting on my profile wall.
Until few months ago, FB would show data from feed method, but now, feed is acting just like share method: it shares url, without image and labels I sent through feed dialog.
All I want is to share image from app, and url of that image should point to app url.
Any suggestions?
I came across this issue from yesterday. The issue only happens when you pass in the FB app link url to the Link option. The works fine with the images as long as the link url is not anything related to FB.
So the workaround I found was to get a shortened URL from google and passed it instead of the normal app link.
FB.ui({
name: 'temp',
method: 'feed',
picture: '',
link: '{shortened url}',
caption: 'temp',
description: 'temp',
redirect_uri: 'any url'
}, function(response){
});
You can try this code to share image from FB app:
FB.ui(
{
method: 'feed',
display: 'popup', // must be one of "popup", "dialog", "iframe", "touch", "async", "hidden", or "none"
name: 'Title for share',
description: 'Description for share',
caption: 'www.facebook.com/YourFbPage/app_xxxxxxxxxxxxxxxxxxx',
link: 'http://PathToYourDomain.com/Folder/',
picture: 'http://PathToYourDomain.com/Folder/img/img-1200x627.jpg',
},function(response) {
if (response && response.post_id) {
// alert('Post was published.');
} else {
// alert('Post was not published.');
}
}
);
Best and good luck!
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object : {
'og:url': str_href,
'og:title': 'title', //galleryItem.title,
'og:description': 'desc', //galleryItem.description,
'og:og:image:width': '2560',
'og:image:height': '960',
'og:image': str_picture //BASE_URL + '/images/works/galleries'
}
})
});
I am working with the FB Javascript send dialogue. I am wanting the iframe/popup to redirect to another url so I can mark that the FB message has been sent. However redirect_uri doesn't seem to be working.
<script>
function test(){
FB.init({appId: 'xxxxxxxxxx', xfbml: true, cookie: true});
FB.getLoginStatus(function(response) {
//call dialog her
FB.ui({
method: 'send',
link: 'http://www.google.com',
redirect_uri: 'google.com',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
redirect_uri: 'http://127.0.0.1:4567/home'
});
});
}
</script>
I have the following code on my website:
<a onclick='postToFeed(); return false;'><img style="width: 27px; height: 27px; border: 0px;" src="{$baseurl}/images/fb_m.png"/></a>
<p id='msg'></p>
{literal}
<script>
FB.init({appId: "xxx", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
display: 'iframe',
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>
{/literal}
The links on my website are in the following format:
{$baseurl}/post/{$posts[i].PID}
I was trying to add this string in the "link:" section however it does not share the correct link.
Any ideas will be appreciated. Thanks
Ok, I managed to insert the link correctly. Here is how the link parameter should look:
link: '{/literal}{$baseurl}/post/{$posts[i].PID}{literal}',
Now the popup script posts a correct link such as http://mysite.com/post/1234. However another problem occurred. My website's page is a grid layout, something like pinterest style. Each post has its own link. The script however shares the last post in the grid, no matter on which post I click the share button. If I use the share button as a link, such as:
<a href="http://www.facebook.com/share.php?u={$baseurl}/post/{$posts[i].PID}" onclick=”return fbs_click()” target=”_blank”>share</a>
the correct post is shared.
I need to use the popup feed dialog instead, with the correct link. Any help will be appreciated.
I have read that the Facebook sharer is deprecated, So I wanted to know how can I create a share button in my widget that will work from any domain (not just the app domain), via the js SDK (Preferably).
For example:
I have my app registered on myserver.com
And someone downloaded my widget on hisservers.com, I want the share to work from there and post to his wall.
How can I do so?
You can use the FB.ui Feed dialog to prompt the user to publish a story on their feed, and specify your link in the function. Like so
function postLink() {
var obj = {
method: 'feed',
link: 'http://myserver.com',
picture: 'a_picture',
name: 'My Server',
description: 'Sharing MyServer from HisServer.'
};
function callback(response) {
console.log(response['post_id']);
}
FB.ui(obj, callback);
}
Of course you'll have to also include the proper initialization for the JS SDK.
function postLink() {
var obj = {
method: 'feed',
link: 'http://myserver.com',
picture: 'a_picture',
name: 'My Server',
description: 'Sharing MyServer from HisServer.'
};
function callback(response) {
console.log(response['post_id']);
}
FB.ui(obj, callback);
}
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.');
}
}
);