21,886
社区成员
发帖
与我相关
我的任务
分享
$data = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
if($error=curl_error($ch)){
die($error);
}
curl_close($ch);
$s = 'HTTP/1.1 200 OK Date: Wed, 01 Mar 2017 09:14:06 GMT Content-Type: application/vnd.ehking-v2.0+json Transfer-Encoding: chunked Connection: keep-alive Key: 777777777777777 chantId: 1213123
{"data":"55555555555555555555555555555555555"}
';
preg_match_all('/(Key|chantId|data"):(\s+|")([^"\s]+)/s', $s, $m);
$data = array();
$data['Key'] = $m[3][0];
$data['chantId'] = $m[3][1];
$data['data'] = $m[3][2];
print_r($data);
Array
(
[Key] => 777777777777777
[chantId] => 1213123
[data] => 55555555555555555555555555555555555
)
$s = 'HTTP/1.1 200 OK Date: Wed, 01 Mar 2017 09:14:06 GMT Content-Type: application/vnd.ehking-v2.0+json Transfer-Encoding: chunked Connection: keep-alive Key: 777777777777777 chantId: 1213123
{"data":"55555555555555555555555555555555555"}
';
preg_match_all('/(Key|chantId|data"):(\s+|")([^"\s]+)/s', $s, $m);
print_r($m);
Array
(
[0] => Array
(
[0] => Key: 777777777777777
[1] => chantId: 1213123
[2] => data":"55555555555555555555555555555555555
)
[1] => Array
(
[0] => Key
[1] => chantId
[2] => data"
)
[2] => Array
(
[0] =>
[1] =>
[2] => "
)
[3] => Array
(
[0] => 777777777777777
[1] => 1213123
[2] => 55555555555555555555555555555555555
)
)