Oct 16, 2015
11
Level 1
I can't recieve postfields data
Hello!
I try to make cURL with post method and postdata so:
private static function curl($url, $method, $postFields = null) {
$curlHandler = curl_init();
curl_setopt($curlHandler, CURLOPT_URL, $url);
curl_setopt($curlHandler, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-API-Key:' . env('API_KEY')));
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandler, CURLOPT_FRESH_CONNECT, true);
if ($method == 'POST') {
curl_setopt($curlHandler, CURLOPT_POST, 1);
if ($postFields) {
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $postFields);
}
} elseif (in_array($method, ['PUT', 'PATCH', 'DELETE'])) {
curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
}
$exec = curl_exec($curlHandler);
curl_close($curlHandler);
return json_decode($exec);
}
but when in the function that supposedly recieves the datas, recieves nothing...
public function store(Request $request)
{
return var_dump($request->all());
}
It's empty :(
Someone can help me?
Thanks!!
PD.- postFiel previously in other function I do http_build_query($data, '', '&')
Please or to participate in this conversation.