Hey there. After the cURL POST to the /account/register endpoint I then check the response code. If it’s different to 200 I check the alert stream by doing a GET to /alerts. This is always empty unfortunately.
private function curl_post( ){
if( !isset( $this->data ) || !isset( $this->api_url ) ){
throw new Exception("Data and API URL must be set");
}
error_log(print_R('POSTING to API',TRUE));
/*$this->data = array(
'first_name'=>'anth2onsd',
'last_name'=>'blursdf',
'email'=>'ablearsaasd32@gmail.com',
'locale'=>'en_US',
'password'=>'123123123123',
'passwordc'=>'123123123123',
'user_name'=>'anthony.blauez727z1',
'spiderbro'=>'http://',
);*/
error_log(print_R($this->data,TRUE));
error_log(print_R($this->api_url,TRUE));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->api_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $this->data,
CURLOPT_VERBOSE => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
));
$response = curl_exec($curl);
$code = curl_getinfo($curl,CURLINFO_RESPONSE_CODE);
error_log(print_R($response,TRUE));
curl_close($curl);
error_log(print_R('Response code: '.$code,TRUE));
//check the alerts stream
if( $code != 200 ){
$response = $this->curl_get_alerts( );
}
return $response;
}
public function curl_get_alerts( ){
$url = $this->get_url().$this->get_alert_path();
error_log(print_R('Querying alert stream at '.$url,TRUE));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true
));
$response = curl_exec($curl);
curl_close($curl);
error_log(print_R('Response from ALERTS',TRUE));
error_log(print_R($response,TRUE));
return $response;
}
When I’m logging the response in curl_post and there’s an error, eg the username is already taken, I see that in the response
<!DOCTYPE html><!--\n\n\nUserFrosting\\Support\\Exception\\HttpException: Email is already in use.
But querying the alert stream doesn’t return anything
Querying alert stream at https://userfrosting.test/alerts
Response from ALERTS
(empty)