CURL

2010-12-07 3 views
1
$URL:https://demo.firstach.com/https/TransRequest.asp?Login_ID=someit&Transaction_Key=somekey&Customer_ID=23&Customer_Name=Muhammad Naeem&Customer_Address=Address&Customer_City=city&Customer_State=HI&Customer_Zip=54000&Customer_Phone=--&Customer_Bank_ID=111111118&Customer_Bank_Account=123456789&Account_Type=Business Checking&Transaction_Type=Debit&Frequency=Once&Number_of_Payments=1&Effective_Date=12%2F05%2F2010&Amount_per_Transaction=10.00&Check_No=&Memo=&SECCType=WEB 

$ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,$url); // set url to post to 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
    curl_setopt($ch, CURLOPT_TIMEOUT, 0); // times out after Ns 
    curl_setopt($ch, CURLOPT_FAILONERROR, 0); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 
    curl_setopt($ch, CURLOPT_HEADER, 1); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, 1); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    $result = curl_exec($ch); // run the whole process 

    print_r($result); 

    curl_close($ch); 

をクエリ文字列ファイルを開く時に不正な要求を取得し、私はfile_get_conentとのfopenをも使用しますが、すべてがCURL

以下のリンクを参照してください。詳細については

私を助けてください 、私にBAD REQUESTエラーが戻ってきています あなたが投稿コードassumignまあ

http://www.uqwibble.com/Phase-2/ach.php

答えて

2

が正確である、この行が問題です:

$URL:https://demo.firstach.com/https/TransRequest.asp?Login_ID=someit&Transaction_Key=somekey&Customer_ID=23&Customer_Name=Muhammad Naeem&Customer_Address=Address&Customer_City=city&Customer_State=HI&Customer_Zip=54000&Customer_Phone=--&Customer_Bank_ID=111111118&Customer_Bank_Account=123456789&Account_Type=Business Checking&Transaction_Type=Debit&Frequency=Once&Number_of_Payments=1&Effective_Date=12%2F05%2F2010&Amount_per_Transaction=10.00&Check_No=&Memo=&SECCType=WEB 

ここでは$URLを定義しようとしていますが、cURLで使用するときは$urlを参照しています。 varibalesは大文字と小文字を区別します。次に$URL:が無効です。$url =を使用します。

$baseurl = 'https://demo.firstach.com/https/TransRequest.asp'; 
$params = array(
'Login_ID' => 'someit', 
'Transaction_Key' => 'somekey', 
'Customer_ID'= => 23, 
'Customer_Name' => 'Muhammad Naeem', 
'Customer_Address' => 'Address', 
'Customer_City' => 'city', 
'Customer_State' => 'HI', 
'Customer_Zip' => '54000', 
'Customer_Phone' => '--', 
'Customer_Bank_ID' => '111111118' 
'Customer_Bank_Account' => '123456789' 
'Account_Type' => 'Business Checking' 
'Transaction_Type' => 'Debit' 
'Frequency' => 'Once' 
'Number_of_Payments' => 1, 
'Effective_Date'=> '12/05/2010', 
'Amount_per_Transaction' => '10.00', 
'Check_No'=> '', 
'Memo'=> '', 
'SECCType' => 'WEB' 
); 

$url = sprintf('%s?%s', $baseurl, http_build_query($params)); 

http_build_queryは、すべてのURLエンコードの世話をするその方法を、あなたは起こっていただきました!参照してくださいので、その簡単な手の前に、アレイと連携して追加することができます。

Addiitonally私はこのようなのparamsをエンコードします/ paramtersを削除/変更します。彼らはいけない。この方法は$urlに手動で追加する必要があり、アレイから直接すべてのパラメータの符号化の世話をし、何をしません

curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

:またはそのポスト要求場合は、使用をjsutことができます。

+0

ありがとう、それは動作します。 – Naeem