本文整理汇总了Python中profiles.models.Profile.get_by_username方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_by_username方法的具体用法?Python Profile.get_by_username怎么用?Python Profile.get_by_username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profiles.models.Profile
的用法示例。
在下文中一共展示了Profile.get_by_username方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: weibo_history
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import get_by_username [as 别名]
def weibo_history(request):
import time
username = request.GET.get('username')
user = Profile.get_by_username(username=username)
access_token = user.access_token
client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL)
client.set_access_token(access_token, expires_in=time.time() + 10000)
user_timeline = client.get.statuses__user_timeline(access_token=access_token, uid=user.sns_id)
data = user_timeline['statuses']
data = [d['text'] for d in data]
return HttpResponse(
'\n'.join(data)
)
示例2: weibo_logout
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import get_by_username [as 别名]
def weibo_logout(request):
username = request.GET.get('username', '')
if not username:
return HttpResponse(to_json(ret=401))
user = Profile.get_by_username(username)
if not user:
return HttpResponse(to_json(ret=500))
client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL)
access_token = user.access_token
expires_in = user.expires_in
client.set_access_token(access_token, expires_in)
client.get.account__end_session()
user.logout()
return HttpResponse(to_json(ret=200))