Php 调用RESTAPI使用URL和参数从网站检索数据
嗨,我必须使用url和登录参数以及一些XML参数作为输入,使用PHP从网站获取信息。我对任何API调用都是新手,所以请解释我如何在PHP代码中使用这些参数,并向服务器发出请求以获取信息 当我在soapui中使用它们时,我可以得到演示结果,我需要在PHP中构建同样的结果Php 调用RESTAPI使用URL和参数从网站检索数据,php,api,rest,Php,Api,Rest,嗨,我必须使用url和登录参数以及一些XML参数作为输入,使用PHP从网站获取信息。我对任何API调用都是新手,所以请解释我如何在PHP代码中使用这些参数,并向服务器发出请求以获取信息 当我在soapui中使用它们时,我可以得到演示结果,我需要在PHP中构建同样的结果 https://transact-prelive.litle.com/vap/communicator/online Username: u82917418420715660 Password: dENteSXnXwfqKHF
https://transact-prelive.litle.com/vap/communicator/online
Username: u82917418420715660
Password: dENteSXnXwfqKHF
Merchant Id: 01183990
<litleOnlineRequest version="9.4" xmlns="http://www.litle.com/schema" merchantId="01183990">
<authentication>
<user>u82917418420715660</user>
<password>dENteSXnXwfqKHF</password>
</authentication>
<authorization id="834262" reportGroup="ABC Division" customerId="038945">
<orderId>65347567</orderId>
<amount>40000</amount>
<orderSource>3dsAuthenticated</orderSource>
<billToAddress>
<name>John Smith</name>
<addressLine1>100 Main St</addressLine1>
<city>Boston</city>
<state>MA</state>
<zip>12345</zip>
<email>jsmith@someaddress.com</email>
<phone>555-123-4567</phone>
</billToAddress>
<card>
<type>VI</type>
<number>4000000000000001</number>
<expDate>1209</expDate>
<cardValidationNum>555</cardValidationNum>
</card>
<cardholderAuthentication>
<authenticationValue></authenticationValue>
<authenticationTransactionId></authenticationTransactionId>
</cardholderAuthentication>
</authorization>
</litleOnlineRequest>
https://transact-prelive.litle.com/vap/communicator/online
用户名:u82917418420715660
密码:dENteSXnXwfqKHF
商户编号:01183990
u82917418420715660
齿形xnxwfqkhf
65347567
40000
3dsautenticated
约翰·史密斯
大街100号
波士顿
文科硕士
12345
jsmith@someaddress.com
555-123-4567
不及物动词
4000000000000001
1209
555
您可以使用nusoap库将SOAP与PHP结合使用。下面是一个如何使用它的示例。它与您的查询类似
$this->load->library("lib_nusoap");
$wsdl = "https://transact-prelive.litle.com/vap/communicator/online";
$client = new nusoap_client($wsdl, 'wsdl');
//$client->setCredentials($api_username,$api_password);
$error = $client->getError();
if ($error)
{
echo "\nSOAP Error\n".$error."\n";
return false;
}
else
{
$params = array ('user' => "u82917418420715660 ", 'Password' => "dENteSXnXwfqKHF ");
$result = $client->call('retrive', $params);
if ($client->fault)
{
print_r($result);
print $client->fault;
}
else
{
$result_arr = json_decode($result, true);
}
}
print_r($result_arr);
Nusoap库将处理CURL API调用。您可以使用php CURL函数。查看获取此错误:致命错误:在C:\wamp\www\test\curl.php的对象上下文中不使用$this4@hemanthkumar必须在控制器类的某些函数中使用库加载,并确保它正在扩展CI_控制器。它不在代码点火器中,。我只是在平面PHP中使用它,okey删除第1行,下载Nusoap库,包括并使用它,不打印任何内容,。一切都是空的,。你用这个密码有结果吗?