I am trying to send a message from my server to google cloud server, but I have a problem with it ... i get the server key (key for server applications), install it in this code:
$headers = array( 'Authorization: key=' .My server key, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch);
after sending the message I have this result:
Unauthorized Error 401
I use this ip: 78.47.150.20
but when I use test ip 0.0.0.0/0, I have no problem.
source share