Skip to content

Commit

Permalink
Add SMS support
Browse files Browse the repository at this point in the history
  • Loading branch information
arilotter committed Jan 19, 2015
1 parent 71aeb00 commit 6304373
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pushbullet/pushbullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PushBullet(object):
ME_URL = "https://api.pushbullet.com/v2/users/me"
PUSH_URL = "https://api.pushbullet.com/v2/pushes"
UPLOAD_REQUEST_URL = "https://api.pushbullet.com/v2/upload-request"
EPHEMERALS_URL = "https://api.pushbullet.com/v2/ephemerals"


def __init__(self, api_key):
Expand Down Expand Up @@ -251,6 +252,24 @@ def _push(self, data):
else:
return False, r.json()

def push_sms(self, device, number, message):
data = {
"type": "push",
"push": {
"type": "messaging_extension_reply",
"package_name": "com.pushbullet.android",
"source_user_iden": self.user_info,

This comment has been minimized.

Copy link
@kstep

kstep Feb 9, 2015

This should be self.user_info['iden'], not full user info dict (see richard-better#31).

"target_device_iden": device.device_iden,
"conversation_iden": number,
"message": message
}
}

r = self._session.post(self.EPHEMERALS_URL, data=json.dumps(data))
if r.status_code != requests.codes.ok:
return False, r.json()
return True, r.json()

def refresh(self):
self._load_devices()
self._load_contacts()
Expand Down

0 comments on commit 6304373

Please sign in to comment.