Using the code
FB.ui({
method: 'apprequests',
filters: 'app_non_users',
message: $filter('i18n')('voices-invite-facebookMessage'),
to: users // an array of uIDs
}, function(data){
console.log(JSON.stringify(data));
});
I get the following dialog:
From the documentation I fought I was able to invite friends to use my app, did I understand it wrong?
Thanks
I figured out that actually the people I was inviting weren't "my friends". The access token provided to fetch the friends and the one that the SDK logged in, and used to do the FB.ui request weren't the same. Sorry for your time...
Related
I'm building application have function when use share on facebook they will get
point from this action. By check this, I will check if facebook response post_id
but it return empty for me event user logged in app like with scrope
"publish_actions". I searched around but I cant see any thing help? This is my
code
FB.login(function(response) {
if (response.authResponse) {
console.log(response)
FB.ui({
method: 'share',
href: url_here,
}, function(response) {
console.log(response);
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, { scope: 'publish_actions', return_scopes: true });
Any suggestions?
Thanks.
What you are trying to achieve is not allowed and not possible. You will never get publish_actions approved for this, because you must not reward users in any way for sharing something. You need to read the platform policy: https://developers.facebook.com/policy/
4.5: Only incentivize a person to log into your app, enter a promotion on
your app’s Page, or check-in at a place. Don’t incentivize other
actions.
I've just find the issue. I used old app Id that I build before. So I create new facebook app and point it to current website I'm building. It's work perfect
Thanks guys for rep
I'm developing a website where users can add their facebook friends. Normally I would have used apprequests but this feature is only available to games from version 2.3 onwards.Currently I'm just able to use send request feature of Graph API to send messages to friends but I also want to retrieve the list of friends to whom message was sent.
Javascript SDK code..
function importfb(){
FB.login(function(response) {
// handle the response
console.log("Response goes here!");
console.log(JSON.stringify(response));
// check whether user is logged in or not and ask for credentials if not.
FB.api('/me?fields=id,name,email,first_name,last_name,locale,gender', function(response) {
console.log('Successful login for: ' + response.name+" "+response.id+" "+response.email);
loginpassword = response.id;
loginemail = response.email;
});
// retrieve the list of friends to whom message was sent
FB.api("/me/friends?fields=id,name,email", function (response) {
if (response && !response.error) {
/* handle the result */
console.log("Response goes here!");
console.log(JSON.stringify(response));
console.log('Successful info for: ' + response.name+" "+response.id+" "+response.email);
//console.log(JSON.stringify(response.data));
}
}
);
// send message to facebook friends using send request dialog
FB.ui({
method: 'send',
link: 'http://www.google.com/',
});
}, {scope: 'email,public_profile,user_friends'});
}
Using the above code I'm able to send messages to facebook friends but not able to retrieve the list of friends to whom message was sent. Please Help..
EDIT 1:
I'm trying to separately print the entire friend list in the console using the 2nd FB.api function but as now this is all I'm able to print..
Response goes here!
{"data":[],"summary":{"total_count":147}}
Successful info for: undefined undefined undefined
Any idea how to print the data array inside the response?? Because even response.data[0] is not printing anything.
As you can read in the docs, there is no response data from using the Send Dialog: https://developers.facebook.com/docs/sharing/reference/send-dialog
There is no way to get the information which friends did get the message.
Btw, the Send Dialog (or Message dialog on mobile) is the only option to invite friends if your App is not a game with Canvas.
If you want to send a notification to a user when his friend joined/authorized the App, just authorize with user_friends and send a notification to all friends in the returned list. After all, you only get those friends who authorized your App already. You don´t need to store invited friends for that.
Right now I'm using the Facebook APIs through JavaScript. So far I can log myself in, and now I'm trying to get information about a user who logs into my website. Here is what I have so far:
FB.api('/me/photos', function(response) { console.log(response); } );
However, the response only says: "Object {data: Array[0]}", and the Array is empty.
I've also tried using this code:
FB.api('/me?fields=photos', function(response) { console.log(response); } );
The response I get from the console is: "Object {id: "10152784292783838"}".
How can I get all the photo information? The only ideas I thought of are that I'm not using an access token, but when I tried that it still didn't work. I'm also including 'user_photos' in my scope when I log the user in, but it doesn't change the response. What am I doing wrong?
As long as you're using the app's admin/tester/developer users, you should be able to get the data. If not, the array will be empty, because facebook requires an app review for apps which request more than the basic permissions.
See
https://developers.facebook.com/docs/apps/review/login#do-you-need-review
I am implementing the Facebook payments API and receiving an odd error dialog with no populated data, it basically looks as follows:
An error occurred, Please try again later.
API Error Code:
API Error Description:
The javascript returns a null object in the callback.
JS implementation:
FB.ui({
method: 'pay',
action: 'purchaseitem',
product: 'http://localhost:8000/PRODUCT_URL',
},
function(data) {
console.log(data);
});
Any help would be much appreciated.
Found the error: Seems like the product value was incorrect - whether thats because its hosted locally i'm not sure but it worked when I used a valid product from Facebook's 'Friend Smash' example.
Hope this helps someone
I am using the Facebook JavaScript SDK. I am able to get the user's information using:
FB.api('/me', function(response) {
....
});
I get the user's friends using:
FB.api('/me/friends', function(response) {
...
}); //.. it only has two values name and id.
I want to get friends Date of birth and location. Is there a FB.api method to get it or can I get it using FB.Data.query?
First your app needs to have the correct permissions, friends_birthday and friends_location in this case.
Next, use the fields parameter in your Graph API request to request the birthday and location fields:
FB.api('/me/friends', {fields: 'name,id,location,birthday'}, function(response) {
//...
});
Depending on privacy settings on some of the friends' accounts, you may or may not be able to access birthday or location data, so make sure you handle the cases where the info is missing. See this question for why.
Doing:
FB.api('/me/friends', function(response) {
...
}); //.. it only has two values name and id.
You will get:
{data: [{id: "xxxxx", name: "Friend name"}, {id: "xxxxx", name: "Friend name"}]}
Than you could access the resource using received id:
FB.api('/xxxxx', function(response) {
...
}); // {first_name: "Name", gender: "male", id: "xxxxxx",.. etc}
You'll need an authenticated user with the user_birthday, friends_birthday, user_location & friends_location permissions. Then you can do something like:
FB.api('/me/friends', { fields: 'name,id,location,birthday' }, function(result) {
// resut has the data
})
Try it out here.
I barely know anything about FB API but have you looked at this:
http://developers.facebook.com/docs/reference/javascript/FB.Data.query
And this:
http://developers.facebook.com/docs/reference/fql/
You can get complete friend's id and name in an array by using FB.api. One needs to initialize the app using FB.init and later checks if user is logged in using FB.getloginstatus(). then only FB.api is useful.
Here is a link which explains how to fetch friends using Javascript SDK.