Solved

Web Services using nusoap

Posted on 2003-11-09
3
236 Views
Last Modified: 2008-03-03
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
Comment
Question by:Senyonjo
3 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 250 total points
ID: 9719167
try replacing <form method=get action=".$PHP_SELF."> with <form method=get action=".$_SERVER["PHP_SELF"].">

loz
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now