Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Web Services using nusoap

The code below is intented to provide me with capacity to consume a webservice with textanywhere.net.

I would like to enable the capability to check the validity of a Mobile Phone Number that could be located anywhere in the world.  On execution, I get no response.  I'm sure that my code is not correct.  Can someone identify what is wrong with it.  the code for the webservice is located         at: http://ws.textanywhere.net/ta_sms.asmx
live example at: http://ws.textanywhere.net/sample.asp

I am using php

Michael Senyonjo
==============================================
 <?php
/* Coucou les copains :) c'est trop facile le php :)
* Company Information
* This script is a webservice client that consumes the webservice with
* WSDL document at http://www.flash-db.com/services/ws/companyInfo.wsdl 
* http://ws.textanywhere.net/ta_sms.asmx
* Given any mobile phone number, it queries the webservice for information about
* that number  and it retrieves the results from the webservice
* for display.
*
* A live demo of this program can be found at
* http://ws.textanywhere.net/sample.asp
*
*
*/

 // Include the NuSOAP soap toolkit file.
require_once('nusoap.php');

 // Create a SOAP Client object.
 $client = new soapclient("http://ws.textanywhere.net/TA_WS");

 // The following is a mechanism for capturing the stock symbol we want
 // to lookup. You can change this as required.
 $number = $_GET['number'];

 // Arguments for the webservice.
 $param = array ("username"=>"Lxxxxx3", "pyyyyyd"=>"51xo0n3", "ticker"=>$number);

 // Call the webservice "textanywhere.net/TA_WS" method with the arguments.
 $results = $client->call("textanywhere.net/TA_WS", $param);

 /* $results is an array with the following structure

*/

 // We would now format the data for output in HTML.
 $html = "<html>\n<head>\n<title>Mobile Phone Number Information. Webservice client - Written by: Tim Akinbo</title>\n</head>\n";
 $html .= "<body>\n";
 $html .= "<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"300\" bgcolor=\"#CCCCCC\">\n<tr>\n";
 $html .= "<td><font face=\"Tahoma, Arial\" size=\"2\">&nbsp;Mobile Phone Number Information</font></td>\n";
 $html .= "</tr>\n<tr>\n<td>\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\" bgcolor=\"#FFFFFF\">\n<tr>\n";
 $html .= "<td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Phone Number</strong></font></td><td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Country</strong></font></td><td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Credit Available</strong></font></td>\n</tr>\n";

 $color = "#000000";

 // $color is set to green if we have an appreciation in value (number is present in $results['textanywhere.net/TA_WS'])
 //if (preg_match("/^\+/", $results['changePercent'])) $color = "#00CC33";
 //if ($number == ($results = $client->call("textanywhere.net/TA_WS", $param))  $color = "#00CC33";
 if (preg_match("$number", $results['textanywhere.net/TA_WS'])) $color = "#00CC33";

 // else it is set to red if we have a depreciation ("-")
 //if (preg_match("/^-/", $results['changePercent'])) $color = "#FF0000";

 $html .= "<tr>\n<td><font face=\"Tahoma, Arial\" size=\"1\">" . $results['number'] . "</font></td><td><font face=\"Tahoma, Arial\" size=\"1\">" . $results['country'] . "</font></td><td><font face=\"Tahoma, Arial\" size=\"1\" color=\"$color\"><strong>" . $results['credit'] . "</strong></font></td>\n</tr>\n";
 $html .= "</table>\n</td>\n</tr>\n</table>\n</body>\n<form method=get action=".$PHP_SELF."><font face=\"Tahoma, Arial\" size=\"1\"><strong>Number to Call : (must start with '+')</strong></font><input type=text name=number><input type=submit value=Check Number></form></html>";

 echo $html;
?>

Michael
==========
0
Senyonjo
Asked:
Senyonjo
1 Solution
 
lozlozCommented:
try replacing <form method=get action=".$PHP_SELF."> with <form method=get action=".$_SERVER["PHP_SELF"].">

loz
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now