問題描述
有沒有一種方法可以在不要求用戶登錄的情況下將 Facebook 內容(特別是來自公共頁面的墻貼)顯示在網站上?在離線訪問權限被棄用之前,我會簡單地創建一個令牌作為我自己,存儲它,并根據需要提取信息.
Is there a way to pull Facebook content (specifically wall posts from a public page) to display on a website without Facebook requiring a user login? Before the offline_access permission was deprecated, I would simply create a token as myself, store it, and pull the information as needed.
現在,據我所知,我只有兩個選擇:1) 每 60 天手動更新一次該令牌,或 2) 僅向 Facebook 用戶顯示內容并使他們允許"應用程序.顯然#1 不是首選選項,#2 似乎不是很好的做法.
Now, from what I can figure out, the only two options I have are to 1) manually update that token every 60 days, or 2) display the content only to Facebook users AND make them "allow" the app. Obviously #1 is not a preferred option, and #2 doesn't seem like very good practice.
作為參考,我只是嘗試從可公開訪問的頁面墻中提取內容,不需要代表用戶執行任何操作(無墻發帖、無閱讀流等).
For reference, I'm only trying to pull content from a publically accessible page wall and require no action on behalf of the user (no wall posting, no reading stream, etc).
這似乎是一個非常簡單的概念,我覺得我必須遺漏一些東西.我在任何地方都找不到答案.這些真的是我唯一的兩個選擇嗎?任何反饋將不勝感激.
This seems like a really simple concept, and I feel like I have to be missing something. I can't find an answer anywhere. Are these really my only two options? Any feedback would be much appreciate.
更新:
我想我可能已經找到了解決這個問題的方法.隨著 offline_access 被棄用,有一個 fb_exchange_token 選項可用于延長現有令牌的到期時間.撥打以下電話:
I think I may have found a way around this. With offline_access being deprecated, there is an fb_exchange_token option available to extend the expiration of an existing token. With a call to the following:
https://graph.facebook.com/oauth/access_token?client_id={app_id}&client_secret=
{app_secret}&grant_type=fb_exchange_token&fb_exchange_token={existing_token}
您應該會收到一個過期時間延長的令牌.在我的場景中,我將允許應用通過我自己的 Facebook 帳戶,將令牌存儲在我的 PHP 代碼中,并僅使用 cURL 定期更新現有代碼.
you should receive a token with an extended expiration. In my scenario, I will allow the app through my own Facebook account, store the token in my PHP code, and just use cURL to periodically update the existing code.
注意:根據 Facebook 文檔,到期時間每天只能延長一次
推薦答案
假設您擁有該頁面,您可以使用 manage_pages 權限.manage_pages 權限是我可以收集的永久令牌.然后在graph api上使用/feed和相關頁碼拉取信息.
Assuming you own the page you can use the manage_pages permission. The manage_pages permission is a permanent token from what I can gather. Then use /feed on the graph api with the relevant page number to pull the information.
我假設您擁有此頁面.如果您沒有或未獲得明確許可,則您無權刪除此信息.
I am assuming you own this page. If you don't or aren't explicitly given permission then you don't have the rights to pull this information down.
這篇關于向非 Facebook 用戶顯示 Facebook 帖子的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!