如何将api与我们的Web服务集成

时间:2018-06-05 06:43:29

标签: php api web-services soap

我有这个HTML代码

<form action="/domains/login.php">

 </div>

 <div class="container">
 <label for="username"><b>Username</b></label>
 <input type="text" placeholder="Enter Username" name="username" required>

 <label for="password"><b>Password</b></label>
 <input type="password" placeholder="Enter Password" name="password" 
 required>

 <button type="submit">Login</button>
  <label>
  <input type="checkbox" checked="checked" name="remember"> Remember me
 </label>
 </div>

  <div class="container" style="background-color:#f1f1f1">
 <button type="button" class="cancelbtn">Cancel</button>
 <span class="psw">Forgot <a href="#">password?</a></span>
 </div>
 </form>

并且这个PHP代码与api集成     

$soapUrl = "http://202.171.47.206:8080/ResellerAPI/ResellerAPIWs?wsdl"; 
$username = 'username'; 
$password = 'password'; 

$client = new SoapClient($soapUrl); 
$result = $client->login(array('username' => $username, 'password' => 
$password))->return; 

$xml = new SimpleXMLElement($result); 

if ((string) $xml->code === '1000') {   
echo "Login successful";
} else {
 echo "Login failed";
throw new Exception("Error:" . $xml->reason . " -- " . $xml->code);

 } 
?>

即时使用此代码进行集成然后获取此错误

Login failed
Fatal error: Uncaught Exception: Error: Login failed -- 9999 in 
/home/kognifi6/public_html/domains/login.php:16 Stack trace: #0 {main} 
thrown in /home/kognifi6/public_html/domains/login.php on line 16

然后我希望这会解决因为这个肥皂api的新手。

1 个答案:

答案 0 :(得分:-2)

这是db连接的错误,你可以试试这个。和我们一样 https://stackoverflow.com/a/42406096/6870298

去这里