Using the FB.ui to publish a feed with parameter display:popup. When a user selects the "Cancel" or after "Share", the web site specified in the 'redirect_uri' parameter is displayed within the popup. The Facebook documentation states that the popup dialog should be dismissed when the buttons are cancelled.
Here is my code. What am I doing wrong?
<script src='http://connect.facebook.net/en_US/all.js'></script>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: my APP ID, status: true, cookie: true,
xfbml: false, channelUrl: 'MY URL/fb-channel.html'
});
};
function fbShare(title, fbSiteUrl, fbThumbnailUrl, fbSiteDescription) {
var publish = {
method: 'feed',
name: title,
caption: 'MY CAPTION',
description: fbSiteDescription,
picture: fbThumbnailUrl,
link: fbSiteUrl,
redirect_uri: 'MY WEB SITE URL',
actions: [
{ name: 'MY WEB SITE Name', link: 'MY WEB SITE URL' }
],
display: 'popup'
};
function callback(response) {
}
FB.ui(publish, callback);
}
</script>
Related
I am using the code below just as from https://developers.facebook.com/docs/reference/dialogs/feed/ to post to a users wall. However the post does not appear on the wall. Is there something I'm missing?
FB.ui({
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 people.'
}, function(response){});
I have the Javascript SDK connect.facebook.net/en_US/all.js loaded. Do I have to add the following code?
FB.init({
appId: 'xxxXXxxx',
status: true,
cookie: true,
xfbml: true
});
There are many reasons why it might not work. The information you provided is really not sufficient, so I'm just gonna go ahead and list a couple of reasons why it might not work:
make sure you created an application on [Facebook developers] (https://developers.facebook.com/apps/), and have the Site URL correct along with the App Domains
the "xxxXXxxx" in the FB.init() is the application ID generated while creating an app on Facebook.
If you're trying on localhost, it will never work.
Finally, your code should look something like this:
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxXXXxxx', // App ID
channelURL : '../../Vendor/channel.php', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
function postFeed(){
FB.ui({method: 'feed',
picture: 'https://www.example.com/img/fb-post.jpg',
link: "http://www.example.com/",
caption: "example.com",
description: "a small description associated with your post",
}, requestCallback);
}
// Load the SDK Asynchronously
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol
+ '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
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 tried to share on facebook But was not able to share anything.
The code that i have used is:-
In Javascript
FB.init({
appId: 'some id',
cookie: true,
status:true,
xfbml:true,
oauth:true
});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'http://www.example.com',
picture: imageToShare,
name: 'name',
caption: 'This Link is Shared through the some application.',
description: ''
};
function callback(response) {
//document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
In config file
<access uri="http://connect.facebook.net" />
Thanks in advance.
If all you want to do is share something from your app to Facebook you can do this quite easily using Cards.
I wrote a blog post on this here: http://devblog.blackberry.com/2013/02/twitter-and-facebook-cards/
Basically, you're using the BlackBerry invocation framework to invoke the Card, and passing some data to that card.
function invokeFacebook() {
blackberry.invoke.invoke({
target: "Facebook",
action: "bb.action.SHARE",
type: "text/plain",
data: "I’m eating tacos with Alex."
}, onSuccess, onError);
}
If you want to share an image you would just swap out the 'data' attribute with:
uri: 'file://' + pathToFile,
There's also a sample app on our GitHub repo: https://github.com/ctetreault/BB10-WebWorks-Samples/tree/master/invoke/invoker
i want to redirect users to a specific page after they share on facebook, i have found a good answer here at:
redirect user after facebook share and publish
here's the script
<script type="text/javascript">
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
function share_me() {
FB.ui({
method: 'feed',
app_id: 'YOUR_APP_ID',
link: 'SHARE_URL',
picture: 'PIC_URL',
name: 'SHARE_NAME',
caption: 'SHARE_CAPTION',
description: 'SHARE_DESCRIPTION'
},
function(response){
if(response && response.post_id) {
self.location.href = 'SUCCESS_URL'
}
else {
self.location.href = 'CANCEL_URL'
}
});
}
</script>";
<div onclick="share_me()">Share</div>
but when i used the script ,there's no redirect at all, even if the user click "cancel"
please help me with this as am searching for a method like this since 1 week!
Try using another javascript function for redirecting like window.location = "YOUR_PAGE"
Hi guys I have a weird problem with de feed dialog.
It works pefect on Firefox, but when I try to use it on IE or Chrome I got this error "An error occurred. Please try later"
I have tried to fix it but I can't. Can you help me please.
This is the code i'm using to call the dialog.
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_GB/all.js'></script>
<a href="#" onclick='postToFeed(); return false;'>Post Feed</a>
<script>
FB.init({appId: "xxxx", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'http://apps.facebook.com/xxxx',
picture: 'xxxx',
name: 'xxxx',
caption: 'xxxxx',
description: 'xxxxx',
properties: [{text: 'xx', href: 'xx'},],
actions: [{name: 'xx', link: 'xx'}],
};
function callback(response) {
document.getElementById('msg').innerHTML = "Well Done!!";
}
FB.ui(obj, callback);
}
</script>
</script>
A couple of things to try:
1: It could possibly be as simple as the rogue comma in your code here after actions:
actions: [{name: 'xx', link: 'xx'}],
Try removing that, however Chrome should better handle that, but that would have caused an issue with IE!
2: Use the Console to see if any errors are thrown.
3: Add oauth: true to your init statement like so:
FB.init({appId: "xxxx", status: true, cookie: true, oauth: true});
4: Remove the parameters in the call, and add them back in one by one after testing it works with each addition: start with:
var obj = {
method: 'feed',
link: 'http://apps.facebook.com/xxxx',
picture: 'xxxx',
name: 'xxxx',
caption: 'xxxxx',
description: 'xxxxx'
};