I'm trying a simple Share dialogue, invoked via Javascript a website page. I can load the SDK fine:
window.fbAsyncInit = function() {
FB.init({
appId : '{My-App-ID}',
xfbml : true,
version : 'v2.0'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
And my javascript function is taken straight from the FB Docs:
FB.ui(
{
method: 'share',
href: 'https://developers.facebook.com/docs/'
}, function(response){});
The issue is testing. I've created a Test App within my main app for this purpose. My Personal Facebook account is an administrator for this App. When logged into my personal account I can invoke the share dialogue and it works fine.
However when I create a 'Test User' from the Roles -> Test Users section on the App Dashboard and log in as them, I get the following error when trying to invoke the share dialogue:
Sorry, this feature isn't available right now: An error occurred while
processing this request. Please try again later.
Very frustrating as I want to test using a test account. Any clues as to why this isn't working? Many thanks.
Related
I got this message on last thursday.
Recent updates in our app permission policies applied a 90-day expiration to user permissions (permissions pertaining to a user's profile info such as posts, photos, gender, age range).
Effective immediately, this now applies to {my-app}
I have read https://developers.facebook.com/docs/facebook-login/auth-vs-data, and tried to check what happen when after data_access_expires_at time. I wanted to know how API responses change.
However, I found no documents of neither consequence for being out-dated nor way of make access token be out-dated.
I do have procedure for re-gaining access token when an access token is invalid. But does this procedure covers in the case of re-authentication needed?
Facebook does not offer 'reauthorize' but you can build it on your own. Facebook also does not offer a programmatic way to extend tokens. What they do say however if users that authenticate your app remain active with your app - their tokens will never expire. If they are not active with your app - access only lasts 90 days.
What you need to do is to place Facebook's login script on your pages. This basically establishes the 'activity":
<script>
window.fbAsyncInit = function() {
FB.Event.subscribe('auth.statusChange', function(response) {
// don't have to do anything actually
});
FB.init({
appId : '${facebookAppId}',
autoLogAppEvents : true,
status : true, // check login status
xfbml : true,
version : 'v3.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
I want to have a "facebook share" link or button on a web page. The idea is to to share a link and a brief description, identical to twiter. No image or title of page is needed
In the past, the following link worked:-
"http://www.facebook.com/sharer.php?u=" + complete_url + message
Now, facebook ignores the message and it discards the complete url link. Instead it only displays the title of the homepage.
I found this answer on stack overflow:-
Make my own custom Facebook share button.
Having tried it (the script below) - I get the error: 'FB' is undefined
I'd be grateful if you could tell me:-
1. what am I doing wrong?
2. do we have to download the sdk.js from facebook server everytime?
The script is like this:
<html><head>
<script>
function onClick() {
FB.ui({
method: 'share',
href: 'the_complete_url_to_specific_page'
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 'my_facebook_id',
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</head>
<body>
<a href='#' onclick='onClick() ;return false;'> share on FacebookR</a>
</body>
</html>
First of all: No, you do not need to change the API version. Only if you need to use something that is only available in newer versions, check out the changelog once in a while: https://developers.facebook.com/docs/apps/changelog
You get the "FB is undefined" error if the JavaScript is not loaded (yet). Most likely you are not trying your code on a real server (it can also be localhost) but from your file system. You can try adding "https" to the source like this, or (better) test the code on a real server:
js.src = "https://connect.facebook.net/en_US/sdk.js";
The App ID is NOT your User ID, it´s an ID you get after creating an App here: https://developers.facebook.com/apps
Btw, the user can enter the message right when the Share Dialog pops up.
I've created a Facebook App and am using the FB developer tools to share content on a site.
However, when a link is shared it is titled "xxx shared a link via Widget Share Log App". I've seen other sites change this to read something like "xxx shared a link via Irrawaddynews" and I wondered if it was possible to do the same here.
BTW, I'm initiating the Facebook SDK with the code below (as per the instructions here: "shared a link via Widget Share Log App." - but this didn't solve my problem).
window.fbAsyncInit = function() {
FB.init({
appId : '{MY_APP_ID}',
status : true,
xfbml : true
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
In your App ID settings on Facebook, there are a few fields you have to update. We wrote pretty detailed setup instructions for doing this in conjunction with our own share software, but there's a general section beneath that for setting up the Facebook app:
https://naytev.zendesk.com/hc/en-us/articles/202777178-Link-Naytev-to-Your-Facebook-App
#userfuser - you actually don't need their validation, you simply need to make the app active. The process has a pretty terrible UX, and missing fields like "support email" will cause you to not be able to activate without a helpful error message.
I'm using the module "facebook like box" in my homepage:
<div id="fb-root"></div>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
I put this code immediately after body tag and I put this in left side:
<div class="fb-like-box fb-box-laterale" href="http://www.facebook.com/RistorantiRomaRisto.it" data-href="http://www.facebook.com/platform" data-width="190" data-height="380" data-show-faces="true" data-stream="false" data-header="true"></div>
All works done, but I receive this error in console: FB.getLoginStatus() called before calling FB.init()
I've just read other conversation where i read that "You need to load the api asynchronously" and I followed their instructions with no result.
How can I solve it?
This happen because you don't add an appId to the url you set for facebook.
See the complete code Facebook generate here: https://developers.facebook.com/docs/reference/plugins/like/
As you'll see, the url is written like this: //connect.facebook.net/fr_CA/all.js#xfbml=1&appId=YOUR_APP_ID
The presence of this appId, will automatically call FB.init() with basic app settings. But as you removed it, FB isn't calling it's init function, and call .getLoginStatus() directly.
So, go create a app for your website, and add the app Id to the code snippet in order to remove this error.
Hope this help !
I currently have the following situation. On my website, the user can access his settings page. This page features a tab called 'Facebook'. On this page, I have the following code that lets the user allow my website to post to his timeline when completing a certain action:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#appId={APP_ID_HERE}&xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-add-to-timeline" data-show-faces="false" data-mode="button"></div>
When the user clicks the button, it is forwarded to the Add to Timeline dialog. When the user clicks Allow, the user gets redirected back to his settings page on my website.
The question is; how do I get an access token out of this? I need a user access token to post to his timeline, according to this line from the tutorial:
https://graph.facebook.com/me/YOUR_NAMESPACE:cook?recipe=OBJECT_URL&access_token=ACCESS_TOKEN
Just tell user to get log in
<fb:login></fb:login>
and after that, use this code everywhere you want
FB.api(
'/me/NAMESPACE:cook','post', {recipe:'http://samples.ogp.me/214706465259448'},
function(response) {
//posted
});
Where cooking is an object