Facebook API - Friendlist empty result - facebook

I'm using Facebook phonegap plugin for my mobile app project. The problem is I get an empty result for friendlist
js
facebookConnectPlugin.api("/me/friends?fields=picture,name", ["public_profile", "user_friends"],function(
response) {
console.log(JSON.stringify(response.data))
}, function(response) {
console.log(JSON.stringify(response))
});
result
2014-08-10 01:41:29.700 TypeOut[590:60b] new permissions (
installed,
"public_profile",
email,
"user_friends"
)
2014-08-10 01:41:29.701 TypeOut[590:60b] Graph Path = /me/friends?fields=picture,name
2014-08-10 01:41:30.292 TypeOut[590:60b] []
How can I fix this?

It will only return friends that are also using the app

If your app is a game, use Request Dialog. If your app is not a game, and on mobile, use Message Dialog.

Related

Update for Facebook SDK for iOS v4.39.0

I am using cordova in my ionic app. For the Facebook functionality I am getting that "currently uses Facebook SDK for iOS v4.15.1, which relies on the recently deprecated Version 2.7 of the Graph API.
As a result, there is a risk that your app will no longer function if you don't upgrade to Facebook SDK for iOS v4.39.0.
As an admin of this app, please upgrade to the latest SDK as soon as possible to ensure your app's continued performance and to take advantage of new features."
But I am not using Facebook SDK, I am using openfb.js to login the user into the app.
Please confirm how I need to make sure that my app will run smoothly as I am not using this Faceboook SDK.
Here is the code which I am using in my App to use the Facebook functionality:
Also the reference link for OpenFB : https://github.com/ccoenraets/OpenFB
$scope.fbLogin = function(){openFB.init({appId: 'XXXXXXXXXXXXXX'});
openFB.login(
function(result1) {
if(result1.status === 'connected') {
var access_token = result1.authResponse.accessToken;
openFB.api({
path: '/me',
success: function(result) {
var o = {};
o.id=result.id;
o.email = result.email;
o.first_name = result.first_name;
o.last_name = result.last_name;
o.gender = result.gender;
o.name = result.name;
//Hitting some api to get the data
console.log(JSON.stringify(result));
},
error: errorHandler});
} else {
console.log(JSON.stringify(result1));
}
}, {scope: 'publish_actions, email, public_profile, user_friends'});
}

Unable to fetch user using Facebook js sdk v2.10 on Firefox

I am trying to add facebook authentication on our website using Facebook Javascript SDK v2.10. My aim is to login via Facebook and then fetch the user which was authenticated.
The problem I am facing is that on Firefox, I am unable to fetch the authenticated user.
I have created a test page HERE
When you click on the button 'Login via Facebook', the FB.login function is called. When the response is received, I am calling the FB.api function. Following is my code
FB.login(function(response) {
let p1 = document.createElement('p');
p1.innerHTML = "FB.login response follows:<br>"+ JSON.stringify(response);
document.body.appendChild(p1)
FB.api('/me', {fields: 'id,first_name'},
function(response) {
let p2 = document.createElement('p');
p2.innerHTML = "FB.api response follows:<br>"+ JSON.stringify(response);
document.body.appendChild(p2)
});
});
In Chrome,the callback of FB.api is called and the response is received,but, in Firefox, this is not happening. Kindly help me figure out why this is happening
Ok. I was using Facebook sdk in Polymer app. The sdk documentation suggests adding the sdk initialization code in index.html.
But, for Polymer, you need to add the code in the connectedCallback method of your root app (my-app.html if you are using polymer-starter-kit)
For reasons unknown, the webcomponent-loader.js blocks Facebook initialization on Firefox, if sdk code is added in index.html.

Facebook API v2.4 : How to get email id of FB user in cordova fb plugin

I'm using " com.phonegap.plugins.facebookconnect " Cordova plugin for FB login in my Phonegap app. My Facebook app is v2.4 . I'm getting only full name and id as login response.But I need email id of user to complete my login process on app.
But when i'm login with same fb credential in my old app i got all details of user as response.This app is connect with facebook app v2.3
Is there any way to get email id of fb user on login ?
My code :
$cordovaFacebook.login(["public_profile", "email", "user_friends"])
.then(function(success) {
//success
}, function (error) {
//error
});
$cordovaFacebook.api("me", ["public_profile"])
.then(function(success) {
//success
} }, function (error) {
//error
});
Thanks in advance
Search for "Declarative Fields" in the changelog: https://developers.facebook.com/docs/apps/changelog#v2_4
You now have to define the fields you want to get in the API calls. The basic call for the /me endpoint would be like this: /me?fields=name,email

Send Friend request to a facebook user using Facebook Graph API 2.x

I want to send friend request from my app to any facebook user (who is not my friend but I have his app-scoped-facebook id.)
(Just kind of adding 'Add Friend' button in my app)
Is there any way to implement this in facebook API 2.0 and above
Adding friends is not possible through the API
You can call http://www.facebook.com/addfriend.php?id=[USER UID]
Where [USER UID] is a valid facebook user id.
I got one solution but don't know it will be deprecated or not as it is of v1.0
But at present its working :)
FB.ui(
{
method: 'friends',
id: fbid
},
function(data){
console.log(data);
}
);

How to setup Facebook App Request from Unity with Prime31 Social combo plugin?

my problem is this, when the user is asked to select friends from the list and click on Send I receive a Success state from callback but no request is reached from the people selected in the list.
My setup is this:
- my app is a native app for iOS and Android made in Unity
- my app is registered in Facebook developer portal as Game/Puzzle, I set up bundle id, package name, display name and namespace
- my app is not yet published
- I configured the Prime31 Facebook plugin with the appId given from Facebook and Display Name
I send my request like this:
public void AskLifesOnFacebook()
{
var parameters = new Dictionary<string, string>
{
//{ "app_id", "#######my_app_id_number####" },
{ "method", "apprequests" },
{ "title", "My request title" },
{ "message", "My request text" }
};
FacebookCombo.showDialog("apprequests", parameters);
}
But still the friends selector is shown up correctly on an overlay windows, I select friends and send the request but no request is received.
Am I missing something in the configuration of my app on Facebook? Do I need to pass some kind of certification?
From the same app the stream.publish is working correctly and I can publish on user walls.
The setup with Prime31 plugin and the call are correct!
You have to enable "Single Sign On" and "Deep Linking" in Facebook app parameters and add a valid itunes ID for your app (while testing you can put any valid ID, but you should create a itunes connect entry for your app and get the final ID).
When your app is a native iOS app, the users see the notifications only through the Facebook iOS app, so they are guarantee they can open iTunes or run the game.
Global notifications instead (ej: regular browser on PC) are seen if the app is in a Facebook Canvas.