Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

augment code #3

Merged
merged 2 commits into from Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()