![](/img/trans.png)
[英]Get user access token from Graph Api Explore facebook and extend it
[英]How to get user access token from Facebook API with curl
我正在編寫一個從 facebook 檢索我們的營銷數據的程序。 我正在編寫的程序只能使用 curl 來檢索用戶訪問令牌並且沒有 UI,我找到的唯一信息是調用這個 url
Curl('https://graph.facebook.com/oauth/authorize?client_id=1534273216862757&response_type=token&redirect_uri=https://www.facebook.com/connect/login_success.html','GET')
但是,當我發送這個時,我得到了重定向頁面的整個 html 而沒有令牌。
你知道我可以用另一種方法來做到這一點嗎?
謝謝
您只能通過用戶交互獲得用戶令牌,而不能通過 curl 獲得。 它不是那樣工作的,也不應該那樣工作。
不過,您可以使用擴展用戶令牌,它的有效期為 60 天。 之后,用戶必須刷新它。
關於代幣的更多信息:
有一些信息:
https://developers.facebook.com/docs/facebook-login/access-tokens/
您的 access_token 可以是: {your-app_id}|{your-app_secret}
。 注意:它是應用程序令牌,而不是用戶令牌。 它是有限的,因此您不能提出諸如/me
類的請求。
或嘗試此請求以獲取訪問令牌:
https://graph.facebook.com/oauth/access_token?client_id={app_id}&client_secret={app_secret}&grant_type=client_credentials&redirect_uri={redirect_uri}
{redirect_uri} 是您的應用程序的任何路由,並且此 uri 必須位於此頁面的“有效 OAuth 重定向 URI”中: https://developers.facebook.com/apps/{app_id}/fb-login/settings/
: https://developers.facebook.com/apps/{app_id}/fb-login/settings/
{app_id}/fb-login/settings https://developers.facebook.com/apps/{app_id}/fb-login/settings/
我不檢查此解決方案,因為我需要請求一些權限(manage_pages、leads_retrieval)。 我在等待它會被授予。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.