官术网_书友最值得收藏!

Connect to the API

The following are the steps to connect to the API:

  1. Firstly, we import the required libraries as follows:
import requests 
import json 
  1. Create a params variable that contains your access token.
params = {'access_token': 'YOUR_ACCESS_TOKEN'} 
  1. Make a request to the feed for the Mercedes Benz page.
page_url = 'https://graph.facebook.com/v2.8/MercedesBenzFrance/feed' 
result = requests.get(page_url, params = params) 
  1. Parse the results as a JSON.
data = result.json() 

The data field contains a list of messages with the following fields: message, created_at, and id. We will print the content of messages.

for element in data['data']: 
  print(element['message'] 

This simple method helps us access the content of conversations on Facebook pages. We will use this information to perform data mining and extract insights in Chapter 3, Uncovering Brand Activity, Emotions, and Popularity on Facebook.

主站蜘蛛池模板: 依安县| 四川省| 晋城| 石台县| 红原县| 咸阳市| 仁寿县| 遵义市| 青田县| 承德市| 富顺县| 枣强县| 齐齐哈尔市| 安仁县| 松溪县| 称多县| 抚远县| 拉萨市| 土默特右旗| 新沂市| 资源县| 庄河市| 和田县| 印江| 万全县| 青田县| 巴林右旗| 黑河市| 石嘴山市| 泾源县| 沈丘县| 舒城县| 清流县| 全南县| 盖州市| 宜川县| 高要市| 祥云县| 巴塘县| 济宁市| 长宁区|