Exemple #1
0
 def run(self, pk):
     received_sms = ReceivedSMS.objects.get(pk=pk)
     keys_and_values = received_sms.as_tuples()
     profile = received_sms.user.get_profile()
     urlcallback_set = profile.urlcallback_set.filter(name='sms_received')
     resp = [callback(urlcallback.url, keys_and_values)
                 for urlcallback in urlcallback_set]
     return resp
Exemple #2
0
 def send_sms(self, smsc, sender, recipients, text):
     """
     We mimick a FORM post to the given URL and get back an HTML table.
     Got this from http://site.demoru.com/?page_id=27
     
     HTTP 200 OK
     Date	Thu: 03 Jun 2010 18:32:15 GMT
     Connection	Close
     Transfer-Encoding	chunked
     Content-Type	text/html; charset=UTF-8
     
     <table class="widefat" border="0">
         <thead>
             <tr>
                 <th>from</th>
                 <th>to</th>
                 <th>smsc</th>
                 <th>status</th>
                 <th>text</th>
             </tr>
         </thead>
         <tbody>
             <tr>
                 <td>+35566</td>
                 <td>+44778962937</td>
                 <td>ESC-P1Celtel</td>
                 <td>0: Accepted for delivery</td>
                 <td> http://www.mobi-fee.com/link/g.lnk?ID=135</td>
             </tr>
         </tbody>
         <tfoot>
             <tr>
                 <th>from</th>
                 <th>to</th>
                 <th>smsc</th>
                 <th>status</th>
                 <th>text</th>
             </tr>
         </tfoot>
     </table>
             
     """
     if not all([msisdn.startswith('+') for msisdn in recipients]):
         raise E_ScapeException, 'All msisdns should start with a +'
     kwargs = {
         's': sender,
         'r': ','.join(recipients),
         'text': text,
         'smsc': smsc,
         'api_id': self.api_id,
         'send': 'go' # apparently the form submission key
     }
     return parse_response(callback(self.gateway_url, kwargs.items()))
Exemple #3
0
 def run(self, pk, receipt):
     sent_sms = SentSMS.objects.get(pk=pk)
     profile = sent_sms.user.get_profile()
     urlcallback_set = profile.urlcallback_set.filter(name='sms_receipt')
     return [callback(urlcallback.url, receipt.entries())
                 for urlcallback in urlcallback_set]