问题描述
我们正在Facebook的网站上显示饲料。直到昨天,我们可以使用以下网址检索JSON格式的资料: https://www.facebook。 com / feeds / page.php?format = json& id = [id_of_the_page]
但是今天我发现链接被打破了。有没有理由破坏?
有没有办法可以使用新的Graph API访问我的页面的JSON feed?
最后,我能够在我的网站上收到Facebook页面的反馈。以下是恢复Feed的步骤:
步骤1:我登录到Facebook开发人员门户并创建了新的Facebook应用程序(网站)。您可以从以下链接中找到有关如何创建Facebook应用程序的详细信息:
在新创建的应用程序中,您将找到应用程序ID和应用程序秘密值。
步骤2:在我的网站上,我使用应用程序ID和应用程序秘密从Facebook检索access_token。我使用C#,所以我使用的代码行是:
string access_token =;
try {
access_token = webClient.DownloadString(https://graph.facebook.com/oauth/access_token?client_id=616255239999&client_secret=989898989898cacec7c3aabbccddf84b66&grant_type=client_credentials);
}
catch {}
将客户端ID替换为应用ID和客户端密码从上一步复制应用程序秘密值。如果值正确,您将收到以下回复:
access_token = 616255878567492343 | UYgAYWXYztpFGRawnZ2VlTE
步骤3:现在使用从前一阶段检索的访问令牌调用Facebook Graph API来获取Feed:
string facebookjson = webClient.DownloadString(https://graph.facebook.com/v2.2/1730999949494/feed?access_token=616255878567492343|UYgAYWXYztpFGRawnZ2VlTE) ;
URL的构造如下所示:
瞧瞧!您可以通过JSON响应从Facebook页面获取Feed。
We are showing feeds from Facebook on our website. Until yesterday, we were able to retrieve the feeds in JSON format using the URL below:
https://www.facebook.com/feeds/page.php?format=json&id=[id_of_the_page]
But today I found that the link was broken. Is there a reason for it breaking?
And is there a way that I can access the JSON feed for my page using the new Graph API?
Finally I was able to get the Facebook page feeds back on my website. Here goes the steps I followed to restore the feeds:
Step 1: I logged into Facebook developer portal and created new Facebook Application (Website). You can find the details on how create a Facebook App from the following link: How to Create Facebook App
On the newly created app you will find the "App ID" and "App Secret" values.
Step 2: On my website, I used the "App ID" and "App Secret" to retrieve an "access_token" from Facebook. I used C#, so the line of code I used was:
string access_token = "";
try {
access_token = webClient.DownloadString("https://graph.facebook.com/oauth/access_token?client_id=616255239999&client_secret=989898989898acec7c3aabbccddf84b66&grant_type=client_credentials");
}
catch {}
Replace client id with app id and client secret with app secret values copied from the previous step. If the values are correct you will get a response like:
access_token=616255878567492343|UYgAYWXYztpFGRawnZ2VlTE
Step 3: Now use the access token retrieved from the previous stage to call Facebook Graph API to get the feeds:
string facebookjson = webClient.DownloadString("https://graph.facebook.com/v2.2/1730999949494/feed?access_token=616255878567492343|UYgAYWXYztpFGRawnZ2VlTE");
The construct of the URL would like below:
https://graph.facebook.com/v2.2/[your_facebook_page_id]/feed?access_token=[your_access_token_value]
And voila!! You get the feeds from your Facebook page in a JSON response.
这篇关于Facebook RSS feed已停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!