コード例 #1
0
ファイル: sniff.py プロジェクト: BBBSnowball/transwhat
def send_sms(recipient, content):
    sg = sipgate.api(SIPGATE_USERNAME, SIPGATE_PASSWORD, "transwhat")

    default_uri = "sip:[email protected]"
    for own_uri in sg.OwnUriListGet()["OwnUriList"]:
        if own_uri["DefaultUri"]:
            default_uri = own_uri["SipUri"]

            # SessionInitiate may return the following server status codes in case of errors: 501, 502, 506, 520, 525
    return sg.SessionInitiate(
        {"LocalUri": default_uri, "RemoteUri": "sip:%[email protected]" % recipient, "TOS": "text", "Content": content}
    )
コード例 #2
0
def send_sms(recipient, content):
    sg = sipgate.api(SIPGATE_USERNAME, SIPGATE_PASSWORD, 'transwhat')

    default_uri = 'sip:[email protected]'
    for own_uri in sg.OwnUriListGet()['OwnUriList']:
        if own_uri['DefaultUri']:
            default_uri = own_uri['SipUri']

    # SessionInitiate may return the following server status codes in case of errors: 501, 502, 506, 520, 525
    return sg.SessionInitiate({
        'LocalUri': default_uri,
        'RemoteUri': 'sip:%[email protected]' % recipient,
        'TOS': 'text',
        'Content': content
    })
コード例 #3
0
# -*- coding: utf-8 -*-

import sipgate
import json
from sys import stderr

### You may set your Sipgate credentials here in this file or in settings.py (to be created by you):
MY_SIPGATE_USERNAME='******'
MY_SIPGATE_PASSWORD='******'
try:
    from settings import *
except:
    pass

try:
    s = sipgate.api(MY_SIPGATE_USERNAME, MY_SIPGATE_PASSWORD, 'example script')

    ### Query the phonebook
    phonebook = s.PhonebookListGet()
    all_entry_ids = [entry['EntryID'] for entry in phonebook['PhonebookList']]
    all_phonebook_entries = s.PhonebookEntryGet({'EntryIDList': all_entry_ids})
    ### Print all entries (they are vCards)
    print json.dumps(all_phonebook_entries, indent=2)
    ### New API version (different URL, not for basic / plus accounts): print json.dumps( s.EventSummaryGet(), indent=2) 

    ### Query the history for your SIP-ID:
    history = s.HistoryGetByDate()
    print json.dumps(history, indent=2)

    ## Let's find out your default Sipgate Uri:
    default_uri = 'sip:[email protected]'
コード例 #4
0
ファイル: sipgate_sms.py プロジェクト: c7h/SMS_Web
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
send SMS via Sipgate
'''

import sipgate
import json
from SMS_Web.settings import MY_SIPGATE_PASSWORD, MY_SIPGATE_USERNAME

s = sipgate.api(MY_SIPGATE_USERNAME, MY_SIPGATE_PASSWORD, 'UNICEF-Nikolausaktion')

def sendSMS(text, recipient_number):
    '''
    actually send out a message via sipgate SMS
    :param text: text message to send
    :param recipient_number: phonenumber of recipient
    :type recipient_number: basestring
    '''
    #clear number:
    recipient_number = recipient_number.replace("+", "").replace("-", "")
    text = ' '.join(text.splitlines())
    print "sending SMS to", recipient_number, ":", text

    ## SessionInitiate may return the following server status codes in case of errors: 501, 502, 506, 520, 525
    sms = s.SessionInitiate(
        {
            'RemoteUri': 'sip:%[email protected]' % recipient_number, 
            'TOS': 'text', 
            'Content': text
コード例 #5
0
ファイル: sipgate_sms.py プロジェクト: MundtDominik/SMS_Web
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
send SMS via Sipgate
'''

import sipgate
import json
from SMS_Web.settings import MY_SIPGATE_PASSWORD, MY_SIPGATE_USERNAME
    

s = sipgate.api(MY_SIPGATE_USERNAME, MY_SIPGATE_PASSWORD, 'UNICEF-Nikolausaktion')
## Let's find out your default Sipgate Uri:
default_uri = 'sip:[email protected]'
for own_uri in s.OwnUriListGet()['OwnUriList']:
    if own_uri['DefaultUri']: default_uri = own_uri['SipUri']
 

def sendSMS(text, recipient_number):
    #clear number:
    recipient_number = recipient_number.replace("+", "").replace("-", "")
    text = ' '.join(text.splitlines())
    print "sending SMS to", recipient_number, ":", text
    ## SessionInitiate may return the following server status codes in case of errors: 501, 502, 506, 520, 525
    sms = s.SessionInitiate({'LocalUri': default_uri, 'RemoteUri': 'sip:%[email protected]' % recipient_number, 'TOS': 'text', 'Content': text })
    print json.dumps(sms, indent=2)