5 Some tricks using BlueVia for Python

5.1 Debugging BlueVia oAuth calls

>>> s = bluevia.BlueViaOutboundSms()
>>> s.loadAccessToken("Tutorial2.pkl")
True

>>> s.setDebug(True)

>>> s.sendSMS(["447763654962"], "Hello BlueVia")

This will give the following debug information about the request:

url   = https://api.bluevia.com/services/REST/SMS_Sandbox/outbound/requests?alt=json&version=v1

query = alt=json&version=v1

head  = {
    "Content-Type": "application/json",

    "Authorization": "OAuth realm=\"BlueVia\",
        oauth_body_hash=\"ZCY9vVjlzMCHb1kYhjF9b93USkA%3D\",
        oauth_nonce=\"22592124\",
        oauth_timestamp=\"1311953122\",
        oauth_consumer_key=\"yT11072616762766\",
        oauth_signature_method=\"HMAC-SHA1\",
        oauth_version=\"1.0\",
        oauth_token=\"3ad2e5c767ecd549d22a2eb04387c705\",
        oauth_signature=\"WYqd6KzHxCS6l98BiGkea1JnP9A%3D\""
    }

body  = {
  "smsText": {
    "message": "Hello BlueVia", 
    "originAddress": {
      "alias": "3ad2e5c767ecd549d22a2eb04387c705"
    }, 
    "address": {
      "phoneNumber": "44776_6_4_6_"
    }
  }
}

And the following information about the oAuth signature components

base  = POST&https%3A%2F%2Fapi.bluevia.com%2Fservices%2FREST%2FSMS_Sandbox%2Foutbound%2Frequests&alt%3Djson%26oauth_body_hash%3DZCY9vVjlzMCHb1kYhjF9b93USkA%253D%26oauth_consumer_key%3DyT11072616762766%26oauth_nonce%3D22592124%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1311953122%26oauth_token%3D3ad2e5c767ecd549d22a2eb04387c705%26oauth_version%3D1.0%26version%3Dv1

key   = hofF15263457&7da66eaa3b9f234d1894a8758ab13433

You can use this information to compare with your results while you implement BlueVia for another language and you get stuck e.g. with one of the most difficult error messages

'{"ClientException":{"exceptionCategory":"SEC",
                     "exceptionId":1001,
                     "text":"Invalid Consumer Signature. 
                      Consumer Authentication failed:oauth_signature is not right."}}'

5.2 Some specifics of the BlueVia implementation

Send SMS / MMS

Receive SMS / MMS

Advertisings