zf2 中包含无效字符的 Http post return 数据
Http post return data with invalid characters in zf2
Http post return 包含无效字符的数据
$url = 'https://sandbox.itunes.apple.com/verifyReceipt';
$params = array('receipt-data' => 'receipt data');
$params = json_encode($params);
我的密码是
$client = new Client();
$client->setUri($url);
$client->setMethod('POST');
$client->setRawBody($params);
$client->setHeaders(array(
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
));
$client->setAdapter(new Curl());
$response = $client->send();
$res = $response->getContent();
我的输出是这样的
����
如果有人知道这件事请帮助我。
您必须像这样解码来自正文的 JSON 响应:
var_dump(json_decode($response->getBody(), true));
然后你会得到一个正确响应的数组:)
例如:
array(1) { ["status"]=> int(21002) }
Http post return 包含无效字符的数据
$url = 'https://sandbox.itunes.apple.com/verifyReceipt';
$params = array('receipt-data' => 'receipt data');
$params = json_encode($params);
我的密码是
$client = new Client();
$client->setUri($url);
$client->setMethod('POST');
$client->setRawBody($params);
$client->setHeaders(array(
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
));
$client->setAdapter(new Curl());
$response = $client->send();
$res = $response->getContent();
我的输出是这样的
����
如果有人知道这件事请帮助我。
您必须像这样解码来自正文的 JSON 响应:
var_dump(json_decode($response->getBody(), true));
然后你会得到一个正确响应的数组:)
例如:
array(1) { ["status"]=> int(21002) }