2017-05-04 46 views
0

我試圖使用python腳本張貼在FB一個形象,但它提供了以下錯誤 提高GraphAPIError(結果) facebook.GraphAPIError:重複的狀態消息要發佈的Facebook頁面中的圖像使用python

進口的Facebook

def main(): 
    # Fill in the values noted in previous steps here 
    cfg = { 
    "page_id"  : "value", # Step 1 
    "access_token" : "value" # Step 3 
    } 

    api = get_api(cfg) 
    msg = "Tasty and Healthy Curries" 
    status=api.put_wall_post(msg) 
    photo = open("http://www.us2guntur.com/html/htmlimages/us2gsweets_291114.jpg", "rb") 
    graph.put_object("me", "photos", message="You can put a caption here", source=photo.read()) 
    photo.close() 

def get_api(cfg): 
    graph = facebook.GraphAPI(cfg['access_token']) 
    # Get page token to post as the page. You can skip 
    # the following if you want to post as yourself. 
    resp = graph.get_object('me/accounts') 
    page_access_token = None 
    for page in resp['data']: 
    if page['id'] == cfg['page_id']: 
     page_access_token = page['access_token'] 
    graph = facebook.GraphAPI(page_access_token) 
    return graph 
    # You can also skip the above if you get a page token: 
    # http://stackoverflow.com/questions/8231877/facebook-access-token-for-pages 
    # and make that long-lived token as in Step 3 

if __name__ == "__main__": 
    main() 

回答

0

您發佈的代碼可能沒有問題。狀態消息清楚地告訴您,您要發佈的狀態更新已經在您的個人資料上共享。這是Facebook告訴你不要發垃圾郵件的方式。

0

實際上,您不能在很短的時間內一次又一次地發送相同的狀態消息,並且這是來自API的錯誤消息,以避免此類情況和垃圾郵件。每次發帖時只需更改put_object方法的消息屬性。