简体   繁体   中英

How do I use Python to make a HTTPS request to this? and get the ACCESS_TOKN back?

https://graph.facebook.com/

I need to make an HTTPS request to that. And then get the params back. How to do that?

Use libhttp2 :

import httplib2
h = httplib2.Http(".cache")
resp, content = h.request("https://graph.facebook.com/", "GET")


>>> import httplib2
>>> h = httplib2.Http(".cache")
>>> resp, content = h.request("https://graph.facebook.com/", "GET")
>>> print resp
{'status': '200', 'content-length': '26244', 'content-location': 'http://developers.facebook.com/docs/api', 'transfer-encoding': 'chunked', 'set-cookie': 'PHPSESSID=d3cc7702c0fa0ea30eb9fd82cd93aa10; path=/, datr=1273298829-77768393a90862aba5e814235278103be75902e4150eea9368624; expires=Mon, 07-May-2012 06:07:09 GMT; path=/; domain=.facebook.com', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'server': 'Apache/1.3.41.fb2', 'connection': 'close', '-content-encoding': 'gzip', 'pragma': 'no-cache', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'date': 'Sat, 08 May 2010 06:07:09 GMT', 'p3p': 'CP="DSP LAW"', 'content-type': 'text/html; charset=utf-8'}
import urllib2

r = urllib2.urlopen('https://graph.facebook.com')
print r.info()
html = r.read()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM