簡體   English   中英

Facebook:使用 PHP 獲取用戶的 Facebook UID

[英]Facebook: Get user's Facebook UID with PHP

我找到了打印用戶 ID、照片和姓名的方法。 使用 PHP 可以輕松獲取其他類型的信息,但我沒有保存鏈接,也找不到如何操作。

我只想知道獲取用戶 ID 的最簡單方法是什么。 我需要將它保存到我的數據庫中:

<?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]')");
?>

我該怎么做?

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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM