Operator query in Python PHP and Java via new ATI WebService

To facilitate credit management for ATI customers, the system that carries out operator queries, we have made available a new way of carrying out queries via Web Service, informing, together with the operator's RN1, the current credit balance of the account that is carrying out the query. and its due date. In this post we will also see examples of how to perform the query in Python, PHP and Java.

To carry out the query returning additional information, a new separate Web Service was created, which also operates on another port, 9091.

To carry out queries in this new Web Service, you must use the URL: http://lnpcluster.sippulse.com:9091/?num=NUMERO , where NUMERO must be the number to be queried, in the pattern DDD+N8(9) . This way, the system will only return the RN1 of the operator referring to the number.

For the query to also inform the account credit and its validity, the query must be made using this pattern: http://port.sippulse.com:9091/?num=NUMERO

Note that the ret parameter was included in the query URL. With this parameter, the system identifies that the user wants to know information regarding credits.

Below is an example of how to make an operator query using ATI Web Services with some of the most used languages today.

Carrier Query in Python:

#!/usr/bin/python

import urllib, httplib2

number=” # Number to make the operator inquiry

ati_user=” # ATI User

ati_pass=” # Password

ati_url = 'http://port.sippulse.com:9091/?num='+number

h = httplib2.Http(“.cache”)

h.add_credentials(ati_user, ati_pass)

resp = h.request(ati_url, “GET”)[1]

print resp

* Need to install the python-httplib2 package

Carrier Query in PHP:

<?php

$http_user=”; // ATI user

$http_password=”; // Password

$numero=”; // Number to carry out the operator query

$url='http://port.sippulse.com:9091/?num='.$numero;

$crl = curl_init();

$timeout = 5;

curl_setopt($crl, CURLOPT_URL,$url);

curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout);

curl_setopt($crl, CURLOPT_USERPWD, “{$http_user}:{$http_password}”);

$ret = curl_exec($crl);

curl_close($crl);

print $ret;

?>

* Need to install the php5-curl package

Carrier Query in Java:

package br.com.voffice.sippulse;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.URL;

import com.sun.xml.internal.messaging.saaj.util.Base64;

public class ConsumerWSATI {

public static void main(String[] args) {

try {

String name = “”; // ATI user

String password = “”; // Password

Long number = ; // Number to carry out the operator query

String authString = name + “:” + password;

byte[] authEncBytes = Base64.encode(authString.getBytes());

String authStringEnc = new String(authEncBytes);

URL url = new URL(“http://port.sippulse.com:9091/?num=” + number);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setRequestMethod(“GET”);

conn.setRequestProperty(“Authorization”, “Basic ” + authStringEnc);

if (conn.getResponseCode() != 200) {

throw new RuntimeException(“Failed : HTTP error code : ”

+ conn.getResponseCode());

}

BufferedReader br = new BufferedReader(new InputStreamReader(

(conn.getInputStream())));

String output;

while ((output = br.readLine()) != null) {

System.out.println(output);

}

conn.disconnect();

} catch (IOException e) {

e.printStackTrace();

}

}

}

Top return codes

TIM: 55341
CLEAR: 55321
ALIVE: 55320, 55315 and 55323
OI: 55314, 55331 and 55335
NEXTEL: 55377 and 55351

Create your ATI demo account and get 500 free consultations for testing and approval of the service.

Any questions or suggestions? Leave your comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEN