2013-08-07 30 views
0

我正在使用python facebook-sdk並希望找到我的新聞Feed中有位置標記的所有帖子。要獲得所有文章在我的新聞提要,我知道我可以使用這樣的:如果我只想職位與位置python facebook-sdk帖子與位置

graph = facebook.GraphAPI(USER_TOKEN) 
feed = graph.get_connections("me", "home") 

根據facebook's API docs我需要「有=位置」添加參數到URL的末尾通過

feed = graph.get_connections("me", "home") 

產生但當我嘗試

feed = graph.get_connections("me", "home", with='location') 

我得到

SyntaxError: invalid syntax 

我在做什麼錯?

回答

0

由於with是一個Python關鍵字,你不能在函數調用中使用它作爲一個關鍵字參數,如:

any_function(with=5) 

或在我的情況:

feed = graph.get_connections("me", "home", with='location') 

功能定義在Python Facebook的SDK get_connections

def get_connections(self, id, connection_name, **args): 

哪表示您可以通過執行以下操作發送with作爲關鍵字參數:

graph.get_connections('me','home', **{'with':'location'})