|
1 |
| -# python2-sdk |
| 1 | +[]() |
| 2 | +[]() |
| 3 | +[](https://github.com/linkv-io/python-sdk/blob/master/LICENSE) |
| 4 | + |
| 5 | +# python2-sdk |
| 6 | + |
| 7 | +LINKV SDK for the Python2 programming language. |
| 8 | + |
| 9 | +## Download |
| 10 | +```sh |
| 11 | +git clone https://github.com/linkv-io/python2-sdk |
| 12 | +``` |
| 13 | + |
| 14 | +## Install |
| 15 | +```sh |
| 16 | +cd python2-sdk |
| 17 | +python setup.py build |
| 18 | +python setup.py install --record log |
| 19 | +``` |
| 20 | + |
| 21 | +## Uninstall |
| 22 | +```sh |
| 23 | +cat log |xargs rm -rf |
| 24 | +rm -rf build dist linkv_sdk.egg-info log |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```python |
| 30 | +# -*- coding: UTF-8 -*- |
| 31 | + |
| 32 | +from linkv_sdk import linkv_sdk |
| 33 | + |
| 34 | + |
| 35 | +def main(): |
| 36 | + app_id = 'rbaiHjNHQyVprPCBSHevvVvuNynNeTvp' |
| 37 | + app_secret = '87EA975D424238D0A08F772321169816DD016667D5BB577EBAEB820516698416E4F94C28CB55E9FD8E010260E6C8A177C0B078FC098BCF2E9E7D4A9A71BF1EF8FBE49E05E5FC5A6A35C6550592C1DB96DF83F758EAFBC5B342D5D04C9D92B1A82A76E3756E83A4466DA22635A8A9F88901631B5BBBABC8A94577D66E8B000F4B179DA99BAA5E674E4F793D9E60EEF1C3B757006459ABB5E6315E370461EBC8E6B0A7523CA0032D33B5C0CF83264C9D83517C1C94CAB3F48B8D5062F5569D9793982455277C16F183DAE7B6C271F930A160A6CF07139712A9D3ABF85E05F8721B8BB6CAC1C23980227A1D5F31D23FA6567578AEEB6B124AF8FF76040F9598DDC9DE0DA44EF34BBB01B53E2B4713D2D701A9F913BE56F9F5B9B7D8D2006CA910D8BFA0C34C619AB0EEBDAA474E67115532511686992E88C4E32E86D82736B2FE141E9037381757ED02C7D82CA8FC9245700040D7E1E200029416295D891D388D69AC5197A65121B60D42040393FB42BC2769B1E2F649A7A17083F6AB2B1BE6E993' |
| 38 | + |
| 39 | + if not linkv_sdk.init(app_id, app_secret): |
| 40 | + return |
| 41 | + |
| 42 | + live = linkv_sdk.LvLIVE() |
| 43 | + |
| 44 | + third_uid = "test-py-tob" |
| 45 | + a_id = "test" |
| 46 | + r = live.GetTokenByThirdUID(third_uid, a_id, user_name='test-py', |
| 47 | + portrait_uri='http://meet.linkv.sg/app/rank-list/static/img/defaultavatar.cd935fdb.png') |
| 48 | + |
| 49 | + if not r['status']: |
| 50 | + print('live.GetTokenByThirdUID(%s)' % r['error']) |
| 51 | + return |
| 52 | + |
| 53 | + print('token:%s' % r['live_token']) |
| 54 | + live_open_id = r['live_open_id'] |
| 55 | + r1 = live.GetGoldByLiveOpenID(live_open_id) |
| 56 | + if not r1['status']: |
| 57 | + print('live.GetGoldByLiveOpenID(%s)' % r1['error']) |
| 58 | + return |
| 59 | + golds0 = r1['golds'] |
| 60 | + print('golds0:%d' % golds0) |
| 61 | + unique_id = '1231234' |
| 62 | + gold = 10 |
| 63 | + r2 = live.SuccessOrderByLiveOpenID(live_open_id, unique_id, linkv_sdk.OrderTypeAdd, gold, 10, 1, |
| 64 | + linkv_sdk.PlatformTypeH5, '') |
| 65 | + if not r2['status']: |
| 66 | + print('live.SuccessOrderByLiveOpenID(%s)' % r2['error']) |
| 67 | + return |
| 68 | + |
| 69 | + golds1 = r2['golds'] |
| 70 | + print('golds1:%d' % golds1) |
| 71 | + if (gold + golds0) != golds1: |
| 72 | + print('(golds0+gold) != golds1') |
| 73 | + return |
| 74 | + |
| 75 | + unique_id1 = '456456' |
| 76 | + ok = live.ChangeGoldByLiveOpenID(live_open_id, unique_id1, linkv_sdk.OrderTypeDel, gold, 1, 'test del') |
| 77 | + if not ok: |
| 78 | + print('!ok') |
| 79 | + return |
| 80 | + |
| 81 | + r3 = live.GetGoldByLiveOpenID(live_open_id) |
| 82 | + if not r3['status']: |
| 83 | + print('live.GetGoldByLiveOpenID(%s)' % r3['error']) |
| 84 | + return |
| 85 | + golds2 = r3['golds'] |
| 86 | + print('golds2:%d' % golds2) |
| 87 | + |
| 88 | + if golds0 != golds2: |
| 89 | + print('golds0 != golds2') |
| 90 | + |
| 91 | + print('success') |
| 92 | + |
| 93 | + |
| 94 | +if __name__ == "__main__": |
| 95 | + main() |
| 96 | +``` |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +This SDK is distributed under the |
| 101 | +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), |
| 102 | +see LICENSE.txt and NOTICE.txt for more information. |
0 commit comments