我不熟悉穿线。事实上,我以前从未学过。在
我正在尝试使用线程从Facebook检索访问令牌,以便我的访问令牌能够自动扩展,而不必每一小时手动检索一次。在
我要做的是:
所以我在Stackoverflow中看到了一些与线程相关的代码,并尝试了一下。最终,它是可行的,但我如何只收集Facebook访问令牌?谁能帮帮我吗?在
import Queue
import threading
import urllib2
# called by each thread
def get_url(q, url):
q.put(urllib2.urlopen(url).read())
theurls = ["My facebook developer gpaph api explorer URL"]
q = Queue.Queue()
for u in theurls:
t = threading.Thread(target=get_url, args = (q,u))
t.daemon = True
t.start()
s = q.get()
print s
有两件事我不清楚
如https://developers.facebook.com/docs/facebook-login/access-tokens#extending中所述,您可以将短期代币兑换为有效期为60天的长期代币。短命的只在2小时内有效。在
根据您想使用访问令牌做什么,您还可以使用应用程序或(永久)页面访问令牌。它们都不会过期,所以你的问题会得到解决。在
相关问题 更多 >
编程相关推荐