Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from subprocess import *;
- import json
- import urllib
- import csv
- import sys
- web_user = 'admin'
- web_pass = 'admin'
- lyric_ip = '192.168.1.202'
- api_user = 'lyric_api'
- api_pass = 'lyric_api'
- api_version = '0.08'
- url = "http://" + web_user + ":" + web_pass + "@" + lyric_ip + "/cgi-bin/exec"
- class Mensaje:
- estado = -1
- contenido = ""
- destino = ""
- message_id = -1;
- def __init__(self, destino, contenido):
- self.estado = 0
- self.destino = destino
- self.contenido = contenido
- def queue(self, url, api_user, api_pass, api_version):
- args = urllib.urlencode({'cmd': 'api_queue_sms', 'username': api_user, 'password': api_pass, 'content': self.contenido, 'destination': self.destino, 'api_version': api_version})
- print args
- res = urllib.urlopen(url + '?' + args).read()
- obj = json.loads(res)
- if obj['success']:
- mensajes[i].estado = 0
- self.message_id = obj['message_id']
- print 'Mensaje insertado exitosamente. Ticket: ' + str(obj['message_id'])
- return 1
- else:
- mensajes[i].estado = -1
- print 'Error al insertar mensaje. Codigo de error: ' + obj['error_code']
- return -1
- def get_status(self, url, api_user, api_pass, api_version):
- if self.estado == -1 or self.estado >= 2:
- return self.estado
- args = urllib.urlencode({'cmd': 'api_get_status', 'message_id': self.message_id, 'username': api_user, 'password': api_pass, 'api_version': api_version})
- res = urllib.urlopen(url + '?' + args).read()
- obj = json.loads(res)
- if obj['success']:
- self.estado = obj['message_status']
- print 'Ticket: ' + str(self.message_id) + ' Estado: ' + str(self.estado)
- return obj['message_status']
- else:
- print 'Error al consultar estado. Codigo de error: ' + obj['error_code']
- return -1
- file = sys.argv[1]
- csvfile = csv.reader(open(file), delimiter=';');
- mensajes = range(0)
- i = 0
- for row in csvfile:
- mensajes.append(Mensaje(row[0], row[1]))
- mensajes[i].queue(url, api_user, api_pass, api_version)
- i = i + 1
- <?php
- $web_user = 'admin';
- $web_pass = 'admin';
- $lyric_ip = '192.168.1.202';
- $api_user = 'lyric_api';
- $api_pass = 'lyric_api';
- $api_version = '0.08';
- $url = "http://" + $web_user + ":" + $web_pass + "@" + $lyric_ip + "/cgi-bin/exec";
- class mensajedetexto {
- public $estado = -1;
- public $contenido = "";
- public $destino = "";
- public $message_id = -1;
- Public function __construct($destino, $contenido){
- $this->estado=0;
- $this->contenido=$contenido;
- $this->destino=$destino;
- }
- Public function quenue1($url, $api_user, $api_pass, $api_version){
- $info = array(
- 'cmd'=> 'api_queue_sms',
- 'username'=> $api_user,
- 'password'=> $api_pass,
- 'content'=> $this->contenido,
- 'destination'=> $this->destino,
- 'api_version'=> $api_version
- );
- $args = urlencode(json_encode($info));
- echo $args;
- $res = file_get_contents($url + '?' + $args);
- $obj = json_decode($res);
- if ($obj['success']){
- $mensajes->$estado = 0;
- $this->message_id = $obj['message_id'];
- echo 'Mensaje insertado exitosamente. Ticket: ' + str($obj['message_id']);
- return 1;
- }else{
- $mensajes->$estado = -1;
- echo 'Error al insertar mensaje. Codigo de error: ' + $obj['error_code'];
- return -1;
- }
- }
- }
- $gestor = fopen("archivo.csv", "r");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement