Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from hxzqlh/master
augment code
- Loading branch information
Showing
8 changed files
with
187 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
#!/usr/bin/env python | ||
#coding: utf-8 | ||
|
||
import web | ||
import json | ||
import requests | ||
import jwt | ||
import datetime | ||
import calendar | ||
import hashlib | ||
import base64 | ||
import Crypto | ||
import time | ||
import uuid | ||
import mixin_config | ||
|
||
|
||
import mixin_asset_list | ||
|
||
urls = ( | ||
'/', 'index', | ||
'/auth','auth', | ||
'/CNB', 'balanceOfCNB', | ||
'/depositCNB','depositCNB', | ||
'/billionCNB','depositBillionCNB', | ||
'/millionCNB','depositMillionCNB' | ||
|
||
) | ||
|
||
class index: | ||
def GET(self): | ||
web.seeother('https://mixin.one/oauth/authorize?client_id=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&scope=PROFILE:READ') | ||
class balanceOfCNB: | ||
def GET(self): | ||
raise web.seeother('https://mixin.one/oauth/authorize?client_id=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&scope=PROFILE:READ') | ||
def GETlistAsset(self): | ||
raise web.seeother('https://mixin.one/oauth/authorize?client_id=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&scope=PROFILE:READ+ASSETS:READ') | ||
web.seeother('https://mixin.one/oauth/authorize?client_id='+mixin_config.mixin_client_id+'&scope=PROFILE:READ+PHONE:READ+ASSETS:READ') | ||
|
||
class depositCNB: | ||
def GET(self): | ||
raise web.seeother('https://mixin.one/pay?recipient=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&asset=965e5c6e-434c-3fa9-b780-c50f43cd955c&amount=5000&trace=' + str(uuid.uuid1()) + '&memo=TEXT') | ||
|
||
class depositBillionCNB: | ||
def GET(self): | ||
raise web.seeother('https://mixin.one/pay?recipient=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&asset=965e5c6e-434c-3fa9-b780-c50f43cd955c&amount=' + str(10 * 10000 * 10000)+ '&trace=' + str(uuid.uuid1()) + '&memo=DepositeCNBV') | ||
|
||
|
||
class depositMillionCNB: | ||
def GET(self): | ||
raise web.seeother('https://mixin.one/pay?recipient=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&asset=965e5c6e-434c-3fa9-b780-c50f43cd955c&amount=' + str(1000 * 1000)+ '&trace=' + str(uuid.uuid1()) + '&memo=DepositeCNBV') | ||
|
||
|
||
|
||
raise web.seeother('https://mixin.one/pay?recipient='+mixin_config.mixin_client_id+'&asset='+mixin_asset_list.CNB_ASSET_ID+'&amount=5000&trace=' + str(uuid.uuid1()) + '&memo=depositCNB') | ||
|
||
class auth: | ||
def GET(self): | ||
mixindata = web.input(code = "no") | ||
print(mixindata) | ||
if mixindata.code == "no": | ||
return "I don't know you, can not give your bonus" | ||
return "invalid code" | ||
|
||
r = requests.post('https://api.mixin.one/oauth/token', json = {"client_id": mixin_config.mixin_client_id, "code": mixindata.code,"client_secret": mixin_config.mixin_client_secret}) | ||
r = requests.post('https://api.mixin.one/oauth/token', json = {"client_id": mixin_config.mixin_client_id, "code": mixindata.code, "client_secret": mixin_config.mixin_client_secret}) | ||
result = r.json() | ||
print(result) | ||
print(result) | ||
if "data" not in result or "access_token" not in result["data"]: | ||
return "I don't know you, can not give your bonus" | ||
|
||
access_token = result["data"]["access_token"] | ||
personinfo = requests.get('https://api.mixin.one/me', headers = {"Authorization":"Bearer " + access_token}) | ||
userid = personinfo.json()["data"]["user_id"] | ||
print(personinfo.json()) | ||
xin_asset_id = "c94ac88f-4671-3976-b60a-09064f1811e8" | ||
print("check my mixin assets") | ||
cnb_asset_id = '965e5c6e-434c-3fa9-b780-c50f43cd955c' | ||
sendmessage_body = {} | ||
|
||
userid = personinfo.json()["data"]["user_id"] | ||
print(personinfo.json()) | ||
return "You are " + userid | ||
|
||
if __name__ == "__main__": | ||
app = web.application(urls, globals()) | ||
app.run() |
Oops, something went wrong.