Skip to content

Instantly share code, notes, and snippets.

@DonerKebab
Created October 18, 2017 02:10
Show Gist options
  • Save DonerKebab/1b930cc6bc0b828057f6ceadb37257f1 to your computer and use it in GitHub Desktop.
Save DonerKebab/1b930cc6bc0b828057f6ceadb37257f1 to your computer and use it in GitHub Desktop.
A script that auto scan from csv file row by row then publish post using row data
# csv format: content | link_to_website
import requests
import csv
import json
import time
PAGE_ID = 'your_facebook_page_id' # find page id : https://findmyfbid.com
ACCESS_TOKEN = 'your_app_access_token' # https://developers.facebook.com/tools/explorer
REQUEST_FORM = 'https://graph.facebook.com/PAGE_ID/feed?message=TITLE&link=PRODUCT_LINK'
CSV_FILE = 'path_to_csv'
DATA = {'access_token': ACCESS_TOKEN}
with open(CSV_FILE, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in reader:
request_url = REQUEST_FORM.replace('TITLE', row[0]).replace('PRODUCT_LINK', row[1])
requests.post(request_url, DATA)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment