【发布时间】:2019-03-09 15:51:57
【问题描述】:
我正在使用具有指定 url 的现金流文档来尝试返回测试请求,但 dump() 返回此错误..
“V|99E5BB5DF59|000|V226|无效请求\n”
或
控制器必须返回响应(V|99E5BB5DFC6|000|V226|无效请求 给定)。
我的代码..
// jSON URL which should be requested
$json_url = 'https://secure.cashflows.com/gateway/remote';
$username = '5949138'; // authentication
$password = 'Ad368w9XYw'; // authentication
// jSON String for request
$json_string ="auth_id=5949138&auth_pass=Ad368w9XYw&card_num=4000000000000002&card_cvv=123&card_ex
piry=0116&cust_name=Testing&cust_address=My%20house%0AMy%20street%0AMy%20Town&cust_post
code=CB22%205LD&cust_country=GB&cust_ip=123.45.67.89&cust_email=test@test.com&tran_ref=abc123
&tran_amount=9.99&tran_currency=GBP&tran_testmode=0&tran_type=sale&tran_class=ecom";
// Initializing curl
$ch = curl_init( $json_url );
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD,$username . ':' . $password); // authentication
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($json_string));
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
// Getting results
$result = curl_exec($ch); // Getting jSON result string
return new JsonResponse($result);
我不知道是什么导致了问题。
【问题讨论】:
-
会不会是Content-Type的小写t?
-
试过了。不是。
-
我认为您缺少一些参数,请检查他们的文档 .cashflows.com/hubfs/support/kb/remote_api_integration_guide.pdf。 curl 有一个工作示例
标签: php json symfony curl response