Saturday, 28 September 2013

Obtaining "Extended Profile Properties" from Facebook

Obtaining "Extended Profile Properties" from Facebook

I am using
<fb:login-button scope="user_work_history" width...></fb:login_button>
The button works to log a user in... (the expected alert box appears with
uid and accessToken when the below code runs)
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
alert(uid + " " + accessToken);
}});
The problem: when I make a FB.api call, it only works for publicly
available info - such as likes or friends - not extended profile info such
as user_work_history or user_hometown. My guess is that it's ignoring my
scope attribute in the login button, I am in sandbox mode right now and
haven't been able to try with multiple fb accounts but I don't know why it
is not asking about permissions (it did once but only about events, not
work history or education or hometown) when I login.
FB.api('/me', function(response) {
if(response.hometown) {
$.each(response.hometown,function(index,hometown) {
$("#networksDiv").append("<label>"+response.hometown+"</label>"+"<input
type='checkbox' name='"+response.hometown+"'
id='"+response.hometown+"'
title='"+response.hometown+"'</input><br />");
});
The above code returns arrays of [object] and certain calls return
'undefined'
Any help is much appreciated.

No comments:

Post a Comment