<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_52785"> <div class="blockcode"> <div id="code_bZ8"><ol> <li><?$url = 'https://android.googleapis.com/gcm/send';<li>$serverApiKey = "YOUR API KEY AS GENERATED IN API CONSOLE";<li>$reg = "DEVICE REGISTRATION ID";<li>$data = array( <li> 'registration_ids' => array($reg), </li> <li> 'data' => array('yourname' => 'Joe Bloggs'));</li> <li>print(json_encode($data));</li> <li>$client = new Zend_Http_Client($url);</li> <li>$client->setMethod('POST');</li> <li>$client->setHeaders(array("Content-Type" => "application/json", "Authorization" => "key=" . $serverApiKey));</li> <li>$client->setRawData(json_encode($data));</li> <li>$request = $client->request('POST');</li> <li>$body = $request->getBody();</li> <li>$headers = $request->getHeaders();</li> <li>print("<xmp>");var_dump($body);var_dump($headers);</li> <li>?></li> </ol></div> <em onclick="copycode($('code_bZ8'));">复制代码</em> </div> </td></tr></table> <div id="comment_52785" class="cm"> </div> <div id="post_rate_div_52785"></div> <br><br>