0
我想在使用PHP運行時的appengine中使用gcm。以下是代碼,它使用的URLFetch服務PHP GCM appengine
$context = array("https"=>
array("method" => "post",
"content" => json_encode($fields),
"header" => "Content-Type: application/json\r\n" .
"Authorization: key=" . GOOGLE_API_KEY . "\r\n"
)
);
$context = stream_context_create($context);
$result = file_get_contents($url, false, $context);
下面是使用PHP捲曲的原代碼:
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
使用捲翹效果很好,使用網址抓取的AppEngine服務
PHP代碼,但是代碼沒有工作。有人能告訴我我在哪裏做錯了嗎?
你看到什麼錯誤? –
我沒有看到任何錯誤。但是「https://android.googleapis.com/gcm/send」正在重定向到「http://developer.android.com/google/gcm/index.html」,並且沒有發送GCM消息 –
請採取看看我的解決方案。它的工作:沒有找到您所提供的鏈接 http://stackoverflow.com/questions/17998875/googlecloudmessaging-returning-invalidregistration –