开发者

Facebook openID authentication for a company?

I have been implementing a Google/Facebook authentication system on my site. I use their respective service to authenticate开发者_如何学运维 the user, then use the results to instantiate sessions on my end. The Google one is running no problem, but for the Facebook one I have hit a snag.

I can authenticate users with no problem, but when trying to authenticate a company or other Facebook page type, it fails.

For instance, using the GraphAPI, I am able to retrieve the values shown in one of their examples https://graph.facebook.com/btaylor and store it properly.

But when I try to use the same system to authenticate a company ( https://graph.facebook.com/nike for instance), it fails since the objects are not part of the user results returned by the GraphAPI.

Normal stuff setting up the call:

$FBcookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET);
$user = json_decode(file_get_contents_curl('https://graph.facebook.com/me?access_token='.$FBcookie['access_token']));

And when storing results, it works fine as a user:

$_Fname =$user->first_name;
$_Lname =$user->last_name;

But trying to access the expected attributes seen at the Nike example above, nothing gets returned.

I even tried echoing out the object to see whats there:

print('<pre>');
print_r($user);
print('</pre>');

For the user, I see everything, for non-user (company, event or other page type), I see nothing.

Question is, has anyone seen what other objects we may need to query via the GraphAPI? The Facebook developer pages are all over the place and have no real concise tutorials on this.

Any help would be much appreciated ;)


Company/Page info on facebook is as follows:

$user->id;
$user->name;
$user->picture;
$user->link;
$user->likes;
$user->category;
$user->website;
$user->username;
$user->description;
$user->public_transit;

So $user->first_name; and $user->last_name; don't exist.

You could try something like this :

if(empty($user->first_name)&&empty($user->last_name)){

//probably company set $user->username;

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜