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>
Related
I created a facebook app to share articles from a website. When I'm connected from the app's admin account, I can share articles, but when I try to share articles from another account, this error is displayed: An error has occurred, please try again later
This is the used script:
<script>
window.fbAsyncInit = function() {
FB.init({appId: '1488318304714792', status: true, cookie: true,
xfbml: true});
};
(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_single_post').appendChild(e);
}());
$(document).ready(function(){
$('.share_button_single_post').click(function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: '<?php echo utf8_encode(strtoupper($chaine2)); ?>',
link: $("input[type='hidden'][name='"+this.id+"1']").val(),
picture: 'http://www.bdo.com.tn/BDO-facebook-logo.png',
caption: 'www.bdo.com.tn',
description: $("input[type='hidden'][name='"+this.id+"2']").val()+'...',
message: ''
});
});
});
</script>
You'll need to check you're not in sandbox mode first.
Have you gone to "Status and Review" in the option panel on the left, and then clicked "yes" for the question "Do you want to make this app and all its live features available to the general public?"
This should make the app accessible to all FB users.
I am having a hybrid mobile application(should work in android and ios). In which I need to post on facebook wall from my application. Please note its a hybrib app, so I am not supposed to use any java or c code.
I tried the following method , its working in simulator , but not in actual device. Please help me.
<script>
window.fbAsyncInit = function() {
FB.init({
appId : ' my appID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#share_button').live('click', function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: 'HyperArts Blog',
link: 'http://hyperarts.com/blog',
picture: 'http://www.hyperarts.com/_img/TabPress-LOGO-Home.png',
caption: 'I love HyperArts tutorials',
description: 'The HyperArts Blog provides tutorials for all things Facebook',
message: ''
});
});
});
</script>
Thanks
I ran into this. your:
document.location.protocol
which is suppose to pull in the FB SDK is actually "file:///" and thats what gets fed into the url for that FB JS library.
Manually specify http:// or https://
This didnt work for me either on safari webView on IOS so i had to hit the endpoints manually using AJAX.
I'm attempting to add a 'Share your order with your friends' option to our retail based website, and am following the faq based here: https://www.facebook.com/help/?faq=201527026558981
I have managed to manipulate the code as I think is correct, however in the FAQ answers the setup on the App is vague at best.
When testing in dev (on localhost) I'm receiving the following error:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
In the basic settings of the app I have no idea what settings need entering around the auth domain, site url, canvas url etc - I'm new to the facebook dev side of things. As far as I can tell I shouldnt need a site URL, as am not using facebook login. Does the canvas URL need to be populated, and if so, does that mean I then need to create a new page for the content of this app?
The code I'm running is:
<script>
window.fbAsyncInit = function() {
FB.init({appId: '1111111111111', status: true, cookie: true,
xfbml: true});
};
(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>
<script>
function stream_publish(publish_text) {
var publish = {
method: 'stream.publish',
message: publish_text,
attachment: {
name: 'xxxxxxxx',
description: (
'xxxxxxxxx' ),
href: 'http://www.mydomain.com',
media: [
{
type: 'image',
href: 'http://www.mydomain.com',
src: 'http://www.mdomain.com/image',
}
]
},
action_links: [
{ text: 'Buy Now', href: 'http://www.mydomain.com', }
],
user_prompt_message: 'Tell your friends'
};
FB.ui(publish);
}
</script>
Can anyone advise how this should be done and what I'm missing?
Many thanks
Piers
From the error message, you don't have mydomain.com setup in your app settings.
I'm just trying to load the facebook sharer page into an iframe which is in a positioned div with no success.
Here is the code I'm using for the iframe,
<iframe src="http://www.facebook.com/sharer.php?u=http://www.website.com&t=Title Hoes Here"></iframe>
When I view the page its blank and the iframe source is
<iframe src="http://www.facebook.com/sharer.php?u=http://www.website.com&t=Title Hoes Here">
<html>
<body></body>
</html>
</iframe>
If I view the url directly, everything appears properly.
Does facebook block loading the sharer in an iFrame? and what are my alternatives to have the facebook sharer appear in a modal window?
Thanks
Yes, Facebook pretty much blocks all loading of screens inside of iFrames.
If you are using Facebook connect there is some simple javascript methods you can execute to get a dialog on your page, and to boot Facebook will take care a lot of the work it takes to make the screen look nice.
See this link ( http://developers.facebook.com/docs/reference/javascript/FB.ui/ ) or use the code below:
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.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
If you are not using Facebook connect then really your only option to get that exact screen is to throw a pop-up.
Another option would be to use the like/send button plugin, this isn't quite the same functionality but is easier to integrate. http://developers.facebook.com/docs/plugins/
Cheers!
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
The above line in the head.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script>
$(document).ready(function(){
$('#share_button').live('click', function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: '',
link: '',
picture: '',
caption: '',
description: '',
message: ''
});
});
});
</script>
I am using the code below to send an app request to someone.
It works fine; it displays in Facebook notification.
when I click that notification, it redirects to the facebook app page.
I'm unable to make it redirect to the page which exists list of facbook app requests.
How do I make it redirect there?
is there any need to do changes in my facebook app setting ?
<div id="fb-root"></div>
<script>
function FacebookIframeAuthenticator(){
window.fbAsyncInit = function() {
FB.init({
appId: '123456789',
status: true,
logging: false,
cookie: false,
xfbml: true
});
FB.Canvas.setSize({height: 2000});
FB.Canvas.scrollTo(0,0);
FB.Canvas.setAutoResize();
};
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);
}
new FacebookIframeAuthenticator();
function sendInvReq ( friendUid, event ){
FB.ui({
method: 'apprequests',
message: 'I\'d like you to join my professional network on SITE NAME .- DB',
to: friendUid,
data: ''
}
, function(r){
if (r != null && typeof(r) != 'undefined'){
if (r.request_ids){
FB.api('/me/apprequests/?request_ids='+toString(request_ids));
$.ajax({
url: 'http://exapmple.com',
cache:false,
type:'POST',
data:({requestIds: r.request_ids.join(','), x_csrf: csrf}),
dataType: 'json',
complete: function(transport){}
});
}
}
}
);
}
</script>
in your developers page (https://developers.facebook.com/apps/your_app_id/advanced) you must change your application advanced settings "Upgrade to Requests 2.0" to disable
If I understood your question right: you can't control the notification url. It will always automatically redirect to your app url with one or more request_ids as paramter. The only possibility to redirect to your prefered destination is to look for this parameter and react properly.