2016-09-21 7 views
1

私は次のようにxmlで送るべきです。私はそれをPHPで送信したい。次のXMLを送信するPHPカール関数を書く方法を手伝ってもらえますか?securetrading.com決済ゲートウェイのphl curlリクエストを書く方法

POST /xml/ HTTP/1.0 
Content-Type: text/xml;charset=utf-8 
Content-Length: 839 
Accept: text/xml 
Accept-Encoding: gzip 
Authorization: <BASIC AUTH CREDENTIALS HERE> 
User-Agent: <YOUR SOFTWARE VERSION HERE> 
Host: webservices.securetrading.net 
Connection: close 

<requestblock version="3.67"> 
    <alias>[email protected]</alias> 
    <request type="AUTH"> 
    <operation> 
     <sitereference>test_site12345</sitereference> 
     <accounttypedescription>ECOM</accounttypedescription> 
    </operation> 
    <merchant> 
     <orderreference>Example AUTH</orderreference> 
     <termurl>https://www.example.com/termurl.cgi</termurl> 
     <name>Test Merchant</name> 
    </merchant> 
    <customer> 
     <ip>1.2.3.4</ip> 
    </customer> 
    <billing> 
     <amount currencycode="GBP">2115</amount> 
     <town>Bangor</town> 
     <country>GB</country> 
     <payment type="VISA"> 
     <expirydate>10/2031</expirydate> 
     <pan>4111111111111111</pan> 
     <securitycode>123</securitycode> 
     </payment> 
    </billing> 
    <settlement/> 
    </request> 
</requestblock> 

は、php professionalのヘルプが必要です。ここで

+0

申し訳ありませんを使用してXMLデータとして送信することができますサンプルですが、SO _not_無料コーディングサービスです。私はあなたのためにその仕事をするプログラマーを雇うことをお勧めします。 – arkascha

+0

私はcurlで直接xmlを送ることができるコードを見ましたが、私は再びそのURLを見つけることができませんでした。 – user3264863

+0

ちょうどPHPのカールのドキュメントを見て、簡単な例が付属しています。 XMLは特別なものではなく、単なる文字列です。あなたはカールのPOST要求をしなければなりません。あなたは確かにそれを理解することができます。行く! – arkascha

答えて

1

あなたはカール

$url="http://"; // Enter url here 
$curl = curl_init(); 
curl_setopt_array($curl, array(
    CURLOPT_URL => $url, 
    CURLOPT_RETURNTRANSFER => true, 
    CURLOPT_TIMEOUT => 30, 
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 
    CURLOPT_CUSTOMREQUEST => "POST", 
    CURLOPT_POSTFIELDS => "<requestblock version=\"3.67\">\r\n <alias>[email protected]</alias>\r\n <request type=\"AUTH\">\r\n <operation>\r\n  <sitereference>test_site12345</sitereference>\r\n  <accounttypedescription>ECOM</accounttypedescription>\r\n </operation>\r\n <merchant>\r\n  <orderreference>Example AUTH</orderreference>\r\n  <termurl>https://www.example.com/termurl.cgi</termurl>\r\n  <name>Test Merchant</name>\r\n </merchant>\r\n <customer>\r\n  <ip>1.2.3.4</ip>\r\n </customer>\r\n <billing>\r\n  <amount currencycode=\"GBP\">2115</amount>\r\n  <town>Bangor</town>\r\n  <country>GB</country>\r\n  <payment type=\"VISA\">\r\n  <expirydate>10/2031</expirydate>\r\n  <pan>4111111111111111</pan>\r\n  <securitycode>123</securitycode>\r\n  </payment>\r\n </billing>\r\n <settlement/>\r\n </request>\r\n</requestblock>", 
    CURLOPT_HTTPHEADER => array(
     "accept-encoding: application/gzip",   
     "content-type: text/xml" 
    ), 
)); 
$response = curl_exec($curl); 
$err = curl_error($curl); 
curl_close($curl); 
if ($err) { 
    echo "cURL Error #:" . $err; 
} else { 
    echo $response; 
} 
+0

ありがとうrakeshbhai – user3264863

+1

ありがとう。私はちょうどコードのヒントが必要でした。今問題を解決できるようになります。 – user3264863

関連する問題