-2

I am using SMS gateway for sending the SMS messages using the python script. In SMS, I would be sending the users email in URL as get parameter. But whenever I am sending SMS with email address it is displaying @ as "inverted ?" symbol. Please see below for the code:

message = u'Click url http://services.indg.in/sms?email=medasandeep@yahoo.co.on to activate account'

values = {'username' : username,
'password' : password,
'smsservicetype'   : smsservicetype,
'content'    : message,
'mobileno' : numbers,
'senderid'    : senderid
}

url = 'gateway url comes here'

postdata = urllib.urlencode(values)
req = urllib2.Request(url, postdata)
req.add_header("Content-Type","application/x-www-form-urlencoded");
req.add_header("User-Agent","Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");

try:
    response = urllib2.urlopen(req)
    print response
    response_url = response.geturl()
    if response_url==url:
        print 'SMS sent!'
except urllib2.URLError, e:
    print 'Send failed!'
    print e.reason

enter image description here

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284

1 Answers1

0

This seems like an encoding problem

Try:

Content-type: application/x-www-form-urlencoded; charset=utf-8

also put

# -*- coding: utf-8 -*-

In the top of your script.

Otherwise, read the documentation for your gateway and find out, which charset they support/expect.

brunsgaard
  • 5,066
  • 2
  • 16
  • 15