本文整理汇总了Python中storyengine.model.account.Account.api_login方法的典型用法代码示例。如果您正苦于以下问题:Python Account.api_login方法的具体用法?Python Account.api_login怎么用?Python Account.api_login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storyengine.model.account.Account
的用法示例。
在下文中一共展示了Account.api_login方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from storyengine.model.account import Account [as 别名]
# 或者: from storyengine.model.account.Account import api_login [as 别名]
def post(self):
if False == (USER_AGENT in self.request.headers["User-Agent"]):
self.response.out.write(json.dumps({'success':False}))
return
self.response.headers['Content-Type'] = 'application/json'
facebookID = self.request.get('facebookid')
name = self.request.get('name')
access_token = self.request.get('access_token')
expiration_date = self.request.get('expiration_date')
logging.info('id[%s] name[%s]',facebookID, name)
if "" == access_token:
access_token = None
if "" == expiration_date:
expiration_date = None
if None == facebookID :
ret = {}
ret['err'] = 'facebookid'
self.response.out.write(json.dumps(ret))
return
if None == name :
ret = {}
ret['err'] = 'name'
self.response.out.write(json.dumps(ret))
return
ret = Account.api_login(facebookID,access_token,expiration_date,name)
if None != ret['id']:
del ret['id']
ret['id'] = facebookID
self.response.out.write(json.dumps(ret))
示例2: post
# 需要导入模块: from storyengine.model.account import Account [as 别名]
# 或者: from storyengine.model.account.Account import api_login [as 别名]
def post(self):
accountid = self.session.get('accountid')
account = Account.get_by_accountid(accountid)
if 1 != account.mod:
return
testcode = self.request.get('testcode')
assert(testcode)
d = json.loads(testcode)
assert(d)
exp_date = None
det = Account.api_login(d['facebookid'],d['access_token'],exp_date,d['name'])
self.redirect(self.request.url + 'input?result='+str(det))
示例3: get
# 需要导入模块: from storyengine.model.account import Account [as 别名]
# 或者: from storyengine.model.account.Account import api_login [as 别名]
def get(self):
REDIRECT_URL = ROOT_URL+"/login"
args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=REDIRECT_URL)
"""redirect_url points to */login* URL of our app"""
args["client_secret"] = FACEBOOK_APP_SECRET #facebook APP Secret
args["code"] = self.request.get("code")
response = cgi.parse_qs(urllib.urlopen(
"https://graph.facebook.com/oauth/access_token?" +
urllib.urlencode(args)).read())
access_token_ = response["access_token"][-1]
profile = json.load(urllib.urlopen(
"https://graph.facebook.com/me?" +
urllib.urlencode(dict(access_token=access_token_))))
account = Account.get_by_facebookid(profile["id"])
if None == account:
Account.api_login(profile['id'],
access_token_,
"2011-03-23 13:53:39",
profile['name'])
account = Account.get_by_facebookid(profile["id"])
self.session['accountid'] = str(account.key().name())
self.redirect("/")
示例4: test_account_login
# 需要导入模块: from storyengine.model.account import Account [as 别名]
# 或者: from storyengine.model.account.Account import api_login [as 别名]
def test_account_login():
facebookid = "[email protected]"
access_token = "access_token"
exp_date = "2113-03-18 07:07:42"
name = "zedoul"
ret = Account.api_login(facebookid,access_token,exp_date,name)
assert True == ret['success']
assert ret['id']
assert ret['created']
assert ret['prices']
assert ret['money']
assert ret['candy']
assert ret['storyIDs']
assert None != ret['recommend']
assert None != ret['score']
assert ret['maintenance']
assert ret['forceupdate']
assert ret['score_expiration']
assert 1 == ret['rank_expiration_days']