In [1]:
import facebook
In [2]:
access_token = 'EAACUzLmOZC7kBAODqMlhUdJXEtRJJoDWKJMCC32vC1cd9ou4FBrQNUT1pNxHJZBXZBmCl0dwSNPDl6w3YhjI6DLLwquy9AbWCZAlky2ZCiQRboCJkiuiITS8iZAZALVYZAlQP9d1W47s0j60rYeFk94ctCqrZAxST93KxGZBS5L4cRrgZDZD'
In [3]:
api = facebook.GraphAPI(access_token)
In [4]:
api.get_object('aulaspythonfia')
Out[4]:
In [5]:
id_pagina = api.get_object('aulaspythonfia')['id']
print(id_pagina)
In [6]:
api.put_object(id_pagina, "feed", message="Olá Mundo!")
Out[6]:
In [7]:
api.put_object("aulaspythonfia", "feed", message="Hello, world")
Out[7]:
In [8]:
import simplejson as json
In [9]:
paginas = api.get_object('me/accounts')
In [10]:
decodificar = json.dumps(paginas, sort_keys=True, indent=4)
In [11]:
print(decodificar)
Agora precisamos iterar sobre os dados retornados e recuperar o token de acesso da página existente:
In [12]:
for pagina in paginas['data']:
if pagina['id'] == id_pagina:
pagina_token_acesso = pagina['access_token']
In [13]:
print(pagina_token_acesso)
In [14]:
mensagem = 'Python Rocks!!!!'
post_pagina = facebook.GraphAPI(pagina_token_acesso)
In [15]:
post_pagina.put_wall_post(mensagem)
Out[15]:
In [ ]: