簡體   English   中英

如何使用facebook-sdk python在im成員的facebook組中發布

[英]how to post in facebook group that's im member on it using facebook-sdk python

我在facebook群組應用程序中發布帖子,這是我的代碼,但僅在im admin群組中發布,無論如何,使用facebook-sdk python lib在不是im admin的群組中發布嗎? 我的代碼導入facebook

token = "my_acces_token"
graph = facebook.GraphAPI(token)
groups = graph.get_object("me/groups")
group_id = groups['data'][2]['id'] # we take the ID of the first group
for post in groups['data']:
        try:
                 graph.put_object(group_id, "feed", message="from terminal")
                 print "liking topic "+ groups['message']

        except:
                continue

您將無法再獲得自己所屬的組的列表,只能獲得自己管理的組,並且需要使用user_managed_groups權限。 user_groups權限已消失,無法替代。

試試dis Man:D

access_token='Access_token'
import facebook 
graph=facebook.GraphAPI(access_token)
groups = graph.get_connections(id='me', connection_name='groups')
data = groups['data']
for s in data:
    l = s.values()    
    object_id= l[6]
    try:
        graph.put_object(object_id, 'feed',message="hola")
        print('Done, Posted in %s'%l[1].encode('utf-8',errors='ignore'))
    except Exception as e:
        print(e)

print 'Done, Posted in all groups'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM