LoginSignup
1
1

More than 5 years have passed since last update.

Facebook APIをPython SDKで叩いてハマったメモ

Posted at

#coding:utf-8
import json, urllib2
import facebook
from setting import *

def getFriendsFromperson(person_id):
    fb_friends = graph.get_connections(id=person_id, connection_name='events')
    print(fb_friends)

facebook_app_id = 'xxxxxxxx'
facebook_app_secret = 'xxxxxxxxxxxxxxx'
facebook_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
facebook_tedxutokyo_event = '682438141897525'

graph = facebook.GraphAPI(facebook_access_token)
event = graph.get_object(id=facebook_tedxutokyo_event, Connection='invited')
attending = graph.get_connections(id=facebook_tedxutokyo_event , connection_name='maybe', limit= 100)
# attending2 = graph.get_connections(id=facebook_tedxutokyo_event , connection_name='attending')

persons_id = {}
persons_pictures = {}

count = 0

for person in attending['data']:
    person_name = person['name'].encode('utf-8')
    person_id = person['id'].encode('utf-8')
    persons_id[person_name] = person_id
    print(person_id)
    count += 1

print(count)

limitをつけるのがポイント(デフォは25個)

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1