나는 게시물의 데이터를 사용하여 CURL을 통해 데이터 문자열을 보내고 배열의 양식에있는 문자열에도 응답을 수신합니다. 나는 이러한 응답을 실제 Array로 변환하려고 시도하고있다. Heres는 코드가 지금까지 가지고 행동 = "지불" 결과 = "성공 =": 28 34_0 2401_02-29-12_22 "문자열 (배열 형식)을 배열로 변환합니다 - PHP
과 같은 응답을 얻기 위해 사용하는 코드 메신저시험 TRANSACTION_ID :
이받고 응답 문자열 메신저이있다 "to_from ="to "amount ="205.00 "gross ="205.00 " net ="- 0.85 "custom =" "business ="[email protected] "item_name ="XXXXX.XXX " item_code ="제품 이름 3 , "수량 ="1 "transaction_type ="승인 결제 "transaction_status ="보류 중 "transaction_date ="2012-02-29 22:28:34 "processing_rate ="0.85 "discount_fee ="0.00 " first_name ="TESTNAME " last_name = "TESTLNAME"address = " TESTADDRESS " 도시 ="TESTCITY "state_or_province ="AL "국가 ="미국 " zip_or_postal_code ="12345 "전화 ="1234562002 "이메일 ="[email protected] " 선적 ="예 "shipping_address ="TESTADDRESS "shipping_city = "TESTCITY" shipping_state_or_province = "AL"shipping_country = "미국" 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();
?>
카를로스는 인덱스의 일부에 약간의 오차가 받고 있어요에게 있습니다. 그것은 그것의 skiping 같은 값의 일부를 보인다 메시지가 나타납니다 : 오프셋 정의되지 않은 : 1 파일 이름 : 관리자/test.php 줄 번호 : 65 을 줄입니다 PHP는 오류가 심각도를 발생했습니다 : $ result [$ keyvalue [0]] = str_replace (' "', $ keyvalue [1]); –
전달 된 문자열에 공백이 있으면이 메서드는 실패합니다. 'transaction_type = "authorized payment"'당신의 코드는 그것을 [transaction_type] =>인가 된 [payment "] =>'으로 바꾸었다. 이 접근 방식을 사용하는 것이 정규식이나 뭔가를 사용해야하므로 따옴표 안에없는 공백에서만 문자열을 분할 할 수 있습니다. 나는 더 나은 방법이 있어야만한다고 느낀다 ... – octern
foreach 내부에 if 문을 추가 했으므로 이제는 오류를 건너 뛴다. Array ([transaction_id] => 2364_03-01-12_14 : 29 : 40_0 [action] => [지불] [결과] => 실패 [오류] => 98 [errors_meaning] => (98) [customer_errors_meaning] => [처리 _ 시간] => 0.0372) 내가 필요한 주요 열쇠입니다. 감사 –