douhuo1738 2016-03-08 11:19
浏览 36

调用REST API以使用URL和参数从网站检索数据

Hi I have to get an information from a website using url and login parameters and some XML parameters as input Using a PHP. I am new to any API calls so please explain me how can I use these parameters in my PHP code and make a request to a server to get the information When I use these in SOAP UI I can get the demo result, I need to build the same in PHP.

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>
  • 写回答

1条回答 默认 最新

  • douba8048 2016-03-08 11:41
    关注

    You can use nusoap library to use SOAP with PHP. Here is an example how you can use it. It is just similar to your query.

            $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 "
    SOAP Error
    ".$error."
    ";
                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 library will handle CURL API call.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分