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

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.

主站蜘蛛池模板: 长沙县| 和平县| 海伦市| 平陆县| 嘉定区| 大足县| 巴彦淖尔市| 磴口县| 潼南县| 乌兰浩特市| 板桥市| 会泽县| 呼伦贝尔市| 梓潼县| 清原| 清新县| 化隆| 万年县| 隆德县| 呼伦贝尔市| 梅河口市| 汉川市| 宜兰县| 东乌珠穆沁旗| 桐梓县| 安龙县| 长寿区| 西平县| 建阳市| 东辽县| 元朗区| 金沙县| 汶上县| 根河市| 瓮安县| 河东区| 格尔木市| 高陵县| 永泰县| 奇台县| 攀枝花市|