Skip to content

Commit

Permalink
Merge pull request #3 from hxzqlh/master
Browse files Browse the repository at this point in the history
augment code
  • Loading branch information
myrual committed Oct 15, 2018
2 parents 7116e86 + 0274ff7 commit 73ec928
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 477 deletions.
43 changes: 9 additions & 34 deletions README.md
Expand Up @@ -13,46 +13,21 @@ community development resource:
- mixin_dev_resource: https://github.com/myrual/mixin_dev_resource
- MiXin_Player:https://github.com/albertschr/MiXin_Player

## deps

## install pip if it is missing in your OS
```
$ curl “https://bootstrap.pypa.io/get-pip.py" -o “get-pip.py”
$ python get-pip.py
```
### install python27 and pip on centos6.8
https://gist.github.com/dalegaspi/dec44117fa5e7597a559
```
yum install gcc
yum install gcc-c++
yum install python-devel
```
## pre request
```
pip2.7 install web.py
pip2.7 install PyJWT
pip2.7 install websocket-client
pip2.7 install requests
pip2.7 install pycrypto
pip2.7 install cryptography
pip2.7 install pycrypto ecdsa
```
* python2.7
* pip2.7


## run robot
```
python home_cnb_robot.py
## pre-request
```

## run robot as long as possible
```
nohup python home_cnb_robot.py &
pip2.7 install -r requirements.txt
```

## kill program
## run robot
```
ls -ef
kill prociess id
./run.sh
```

## 参考

[中文搭建教程](https://www.jianshu.com/p/727cca139a57)
* [中文搭建教程](https://www.jianshu.com/p/727cca139a57)
57 changes: 13 additions & 44 deletions home_cnb.py
@@ -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()

0 comments on commit 73ec928

Please sign in to comment.