Skip to content

Latest commit

 

History

History
67 lines (48 loc) · 1.37 KB

README.md

File metadata and controls

67 lines (48 loc) · 1.37 KB

RingCentral SDK for Python

Build Status

Installation

Manual

$ git clone https://github.com/ringcentral/python-sdk.git ./ringcentral-python-sdk

Install dependencies:

PIP

$ pip install ringcentral

Usage

For more info take a look on the test.py in this repository.

from ringcentral import SDK

sdk = SDK('APP_KEY', 'APP_SECRET', 'SERVER')
platform = sdk.platform()
platform.login('USERNAME', 'EXTENSION', 'PASSWORD')

res = platform.get('/account/~/extension/~')
print('User loaded ' + res.json().name)

Subscribing for server events

from threading import Thread
from time import sleep
from ringcentral.subscription import Events

def on_message(msg):
    print(msg)

def pubnub():
    s = sdk.create_subscription()
    s.add_events(['/account/~/extension/~/message-store'])
    s.on(Events.notification, on_message)
    s.register()
    while True:
        sleep(0.1)

try:
    try:
        import Pubnub
        t = Thread(target=pubnub)
        t.start()
    except ImportError as e:
        print("No Pubnub SDK, skipping Pubnub test")
        
except KeyboardInterrupt:
    pass