简体   繁体   English

使用facebook api从facebook收集赞,分享,评论

[英]Collecting Like, Share, comments from facebook using facebook api

I am trying to scrape a public facebook page using facebook api, but every time i sent request it return 我正在尝试使用Facebook API刮擦公共Facebook页面,但是每次我发送请求时都会返回

HTTP Error 400: Bad Request HTTP错误400:错误的请求

I am putting correct access token, which is app id + "|" 我输入了正确的访问令牌,即应用程序ID +“ |” + app_secret. + app_secret。 But still return Bad request. 但是仍然返回Bad请求。 For safety reason I hide my app id and app secret code . 出于安全原因,我隐藏了我的应用ID应用密码

import facebook
import urllib3
import requests
from urllib.request import urlopen, Request
import json
import datetime
import csv
import time

app_id = 'facebook_app_id'
app_secret = 'facebook_app_secret' 

access_token = app_id + "|" + app_secret

fb_page = "manchesterunited"



base = "https://graph.facebook.com/v3.2"
node = "/" + fb_page
parameters = "/? 

fields=message,link,created_time,type,name,id,likes.limit(1).summary(true),comments.limit(1).summary(true),shares&limit=%s&access_token=%s" % (100, access_token)
 url = base + node + parameters

def request_until_succeed(url):
    req = Request(url)
    success = False
    while success is False:
        try:
            response = urlopen(req)
            if response.getcode() == 200:
                success = True
        except Exception as e:
            print(e)
            time.sleep(5)

            print("Error for URL %s: %s" % (url, datetime.datetime.now()))

   return response.read()
 test_status = json.loads(request_until_succeed(url))["data"][0]
 print (json.dumps(test_status, indent=4, sort_keys=True))

With a simple App Access Token and a Public Page you do not own, you first need to get approved for Page Public Content Access: https://developers.facebook.com/docs/apps/review/feature/#reference-PAGES_ACCESS 使用简单的App Access令牌和您不拥有的公共页面,首先需要获得页面公共内容访问的批准: https : //developers.facebook.com/docs/apps/review/feature/#reference-PAGES_ACCESS

Alternatively, for testing, you can use a Page Token of a Page you own. 另外,对于测试,您可以使用您拥有的页面的页面令牌。

More information about Tokens: https://developers.facebook.com/docs/facebook-login/access-tokens/ 有关令牌的更多信息: https : //developers.facebook.com/docs/facebook-login/access-tokens/

You can not access public pages any more without getting your app reviewed for this upfront. 在未事先审查您的应用之前,您无法再访问公共页面。

https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS : https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS

Page Public Content Access 页面公共内容访问
Allows read-only access to public data on Pages for which you lack the manage_page login permission. 允许以只读方式访问您缺乏manage_page登录权限的页面上的公共数据。 Readable data includes business metadata, public comments, posts, and reviews. 可读数据包括业务元数据,公共评论,帖子和评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Facebook Graph API发布评论时出错 - Error posting comments using Facebook Graph API 从Facebook API(Python,JSON)中提取注释 - Pull comments from Facebook API (Python, JSON) 使用Python的Instagram API并从每个标题中收集注释 - Instagram API using Python and collecting comments from each caption 使用Python的Facebook API。 如何打印所有帖子的评论? - Facebook API using Python. How to print out comments from ALL post? facebook comments API-Facebook在“评论框后面”是什么意思? - facebook comments API - what does facebook mean by “behind the comments box”? 有没有办法从Facebook页面中抓取Facebook评论和ID,如nytimes或监护人用于分析目的? - Is there a way to scrape Facebook comments and IDs from a Facebook page like nytimes or the guardian for analytical purposes? 谁从使用Facebook API的帖子组中获得评论 - Who get comments from post group with Facebook API 脸书分享API; 推断属性 - facebook share api; Inferred Property 如何在Twitter中分享,例如使用Facebook javascript SDK在Facebook中分享一些文本 - how to share in twitter like sharing some text in facebook using facebook javascript sdk 使用 Selenium 从 Facebook 获取照片的喜欢和评论 - Getting the likes and comments of a photo from Facebook using Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM