本文整理匯總了Python中pyfb.Pyfb.get_user_by_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Pyfb.get_user_by_id方法的具體用法?Python Pyfb.get_user_by_id怎麽用?Python Pyfb.get_user_by_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyfb.Pyfb
的用法示例。
在下文中一共展示了Pyfb.get_user_by_id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setpassword
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import get_user_by_id [as 別名]
def setpassword(request, idnum):
idnum = int(idnum)
try:
fb = FacebookProfiles.objects.get(fbk_id = idnum)
facebook = Pyfb(settings.FACEBOOK_APP_ID)
facebook.set_access_token(fb.fbk_token)
me = facebook.get_user_by_id(id = fb.fbk_id)
user = fb.user
except ObjectDoesNotExist:
return HttpResponseRedirect('/')
if request.method == 'POST':
form = PasswordSetForm(request.POST)
if form.is_valid():
user.set_password(form.cleaned_data['password'])
user.save()
authuser = authenticate(username=user.username, password=form.cleaned_data['password'])
if authuser is not None:
login(request, authuser)
return HttpResponseRedirect('/auth/welcome/')
else:
form = PasswordSetForm()
var = RequestContext(request, {
'form':form,
'me':me,
'user':user
})
return render_to_response('registration/facebook.html', var)