Closed mwhawkins closed 12 years ago
Sample code giving the error:
msg = {'reqtype':'json','password':'12345','from':'123456789','username':'12345','to':'123456789'}
for t in self.get_text_recipients():
msg['to'] = t
sms = NexmoMessage(msg)
sms.set_text_info(self.content)
sms.send_request()
Hello Michael,
thank you for your feedback, I'm going to look into this issue as soon as possible!
Cheers!
Michael,
I guess the problem resides in "get_text_recipients()". What does that function return? I tried to simulate it using this code:
#!/usr/bin/env python
from nexmomessage import NexmoMessage
def get_text_recipients():
return ["+391234567890", "+391234567891"]
msg = {'reqtype':'json','password':'blablabla','from':'123456789',
'username':'blablabla','to':'123456789'}
content = "fool the reader"
for t in get_text_recipients():
msg['to'] = t
sms = NexmoMessage(msg)
sms.set_text_info(content)
print sms.get_details()
print sms.send_request()
and I got both texts delivered instantly.
Please let me know! :)
Yeah - really sorry about this - turns out it was a Django model object I couldn't iterate on and it was being passed in the get_text_recipients function. Really, really sorry about that.
No problem at all! :)
I'll close this issue, have a good time!
When trying to iterate through an array of recipients (for x in array), I tried to create new NexmoMessage objects for each and call the REST API, but I get the "'builtin_function_or_method' object is unsubscriptable" error. It appears there is a builtin function being used that won't allow the iteration to perform.