2014-02-20 52 views
0

我正在尝试使用github oauth。 I'n使用的urllib和urllib2的和有这样的代码:如何通过Django发送GET请求

def github_login(request): 
    post_data = [('client_id','****'),('redirect_uri','http://localhost:8000/callback')] 
    result = urllib2.urlopen('https://github.com/login/oauth/authorize', urllib.urlencode(post_data)) 
    content = result.read() 

和发送的查询后,我有httperror 403.我已经配置在settings.py

+0

PLE ase显示你的完整代码。包括settings.py。你如何在这里使用'settings.py' – nish

+0

好吧,错误403不是从Django的,因为我明白你的desription。它来自github。你的查询出错了。 ANYWAY for auth你可以使用这个应用程序:https://github.com/pennersr/django-allauth – Aldarund

+0

问题已关闭。回答是,urllib2.urlopen发送POST请求,如果给它两个参数。右:urllib2.urlopen('ex.ru?%s'%urllib.urlencode(data)) – prozac631

回答