开发者

Facebook: Get user's Facebook UID with PHP

开发者 https://www.devze.com 2023-03-02 14:47 出处:网络
I had found the way to print the user ID, photo and name. And other type of info easily with PHP but I didn\'t save the link and can\'t find how to do it.

I had found the way to print the user ID, photo and name. And other type of info easily with PHP but I didn't save the link and can't find how to do it.

I only want to know what's the simplest method to get the User's ID. I need to save it to my database in here:

<?php
// Get new icon
mysql_select_db("cyberworlddb", $con);

mysql_query("INSERT IGNORE INTO 开发者_如何转开发Badges (UID, Website, Code)
VALUES ('UID','$urlhost[0]','1$urlhost[0]')");
?>

How can I do it?


If they are logged into your Facebook application you can get their session token from the facebook cookie (http://developers.facebook.com/docs/authentication/) and then you just use the graph api:

$me = json_decode(@file_get_contents('https://graph.facebook.com/me?access_token=' . $cookie['access_token']));

$uid = $me->id;
0

精彩评论

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