讨论数量:
我以前用的代码,不知道能不能帮到你。
//先引入Guzzle的Client命名空间
public static function post($array,$url,$type='json'){
try{
$client = new Client();
$response = $client->request('POST', $url,[
$type => $array,
]);
return json_decode($response->getBody()->getContents(),1);
}catch (ClientException $e){
return json_decode($e->getResponse()->getBody()->getContents(),1);
}catch (ServerException $e){
return json_decode($e->getResponse()->getBody()->getContents(),1);
}
}
推荐文章: