私は、ポストからのデータを使用してCURLを介してデータの文字列を送信し、配列のフォームにある文字列の応答も受け取ります。私はそのような応答を実際の配列に変換しようとしています。私がこれまで持っている相続人コード:配列(配列形式)を配列に変換する - PHP
応答文字列のイム取得はこれです:
そして、このような応答を取得するために使用してコードイムはテストTRANSACTION_IDは= "2401_02-29-12_22:28:34_0" アクションは= "支払い" 結果=「成功"to_from ="から "amount =" 205.00 "gross =" 205.00 " net =" - 0.85 "custom =" "business =" [email protected] "item_name =" XXXXX.XXX " item_code ="製品名3 "processing_rate =" 0.85 "discount_fee =" 0.00 " first_name =" TESTNAME "、" quantity = "1" transaction_type = "承認済み お支払い" transaction_status = "保留中" transaction_date = "2012-02-29 22:28:34" last_name = "TESTLNAME" address = " "TESTADDRESS" 都市= "TESTCITY" state_or_province = "AL" country = "US" zip_or_postal_code = "12345" phone = "1234562002" email = "[email protected]" 出荷= "はい" shipping_address = "TESTADDRESS" shipping_city = "TESTCITY" shipping_state_or_province = "AL" shipping_country = "US" shipping_zip_or_postal_code = "12345" processing_time = "0.2187" は
<?php
// Get variables from POST array into a string
$post_str = "action=payment&business=" .urlencode($this->input->post('business'))
."&vericode=" .urlencode($this->input->post('vericode'))
."&item_name=" .urlencode($this->input->post('item_name'))
."&item_code=" .urlencode($this->input->post('item_code'))
."&quantity=" .urlencode($this->input->post('quantity'))
."&amount=" .urlencode($this->input->post('amount'))
."&cc_type=" .urlencode($this->input->post('cc_type'))
."&cc_number=" .urlencode($this->input->post('cc_number'))
."&cc_expdate=" .urlencode($this->input->post('cc_expdate_year')).urlencode($this->input->post('cc_expdate_month'))
."&cc_security_code=" .urlencode($this->input->post('cc_security_code'))
."&shipment=" .urlencode($this->input->post('shipment'))
."&first_name=" .urlencode($this->input->post('first_name'))
."&last_name=" .urlencode($this->input->post('last_name'))
."&address=" .urlencode($this->input->post('address'))
."&city=" .urlencode($this->input->post('city'))
."&state_or_province=" .urlencode($this->input->post('state_or_province'))
."&zip_or_postal_code=" .urlencode($this->input->post('zip_or_postal_code'))
."&country=" .urlencode($this->input->post('country'))
."&shipping_address=" .urlencode($this->input->post('shipping_address'))
."&shipping_city=" .urlencode($this->input->post('shipping_city'))
."&shipping_state_or_province=" .urlencode($this->input->post('shipping_state_or_province'))
."&shipping_zip_or_postal_code=".urlencode($this->input->post('shipping_zip_or_postal_code'))
."&shipping_country=" .urlencode($this->input->post('shipping_country'))
."&phone=" .urlencode($this->input->post('phone'))
."&email=" .urlencode($this->input->post('email'))
."&ip_address=" .urlencode($this->input->post('ip_address'))
."&website_unique_id=" .urlencode($this->input->post('website_unique_id'));
// Send URL string via CURL
$backendUrl = "https://www.veripayment.com/integration/index.php";
$this->curl->create($backendUrl);
$this->curl->post($post_str);
// get response from API
$return_str = $this->curl->execute();
?>
カルロスです。 A PHPエラーが 重大度発生しました:オフセット不定: メッセージに注意してください1 をファイル名:管理者/ test.phpを 行番号:65 ラインがあることは、値のいくつかのそのskipingのように思えます:$ result [$ keyvalue [0]] = str_replace( '"'、$ keyvalue [1]); –
渡された文字列の中に空白が含まれていると、このメソッドは失敗します。あなたのコードは '[transaction_type] => authorized [payment"] => 'に変換しました。 このアプローチを動作させると、引用符で囲まれていないスペースでのみ文字列を分割できるように、正規表現などを使用する必要があります。私は良い方法が必要であるように感じる... – octern
私はforeach内のifステートメントを追加したので、エラーをスキップして、今はArray([transaction_id] => 2364_03-01-12_14:29:40_0 [action] =>支払い[結果] =>失敗[エラー] => 98 [errors_meaning] =>(98)[customer_errors_meaning] => [processing_time] => 0.0372) 私は必要なメインキーです。ありがとう –