建立新浪雲計算平臺應用


Sina App Engine(下面簡稱SAE)是新浪研發中心於2009年8月開始內部開發,並在2009年11月3日正式推出第一個Alpha版本號的國內首個公有云計算平臺,SAE是新浪雲計算戰略的核心組成部分。

咱們先申請一個帳號:直接訪問http://sae.sina.com.cn

註冊成功後,咱們就可以進入管理系統
選擇建立SAE
這裏選擇PHP的。也可以選用其餘語言哦


建立成功後,咱們可以看見兩個版本號控制系統哦,因爲我比較熟悉SVN。因此就下載了TortoiseSVN
提供下載官網和網盤:

注意要建立一個版本哦
而後選擇上傳代碼包。提供微信接口代碼
<?

php /** * wechat php test */ //define your token define("TOKEN", "weixin"); $wechatObj = new wechatCallbackapiTest(); $wechatObj->valid(); class wechatCallbackapiTest { public function valid() { $echoStr = $_GET["echostr"]; //valid signature , option if($this->checkSignature()){ echo $echoStr; exit; } } public function responseMsg() { //get post data, May be due to the different environments $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //extract post data if (!empty($postStr)){ $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $time = time(); $textTpl = "<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Content><![CDATA[%s]]></Content> <FuncFlag>0</FuncFlag> </xml>"; if(!empty( $keyword )) { $msgType = "text"; $contentStr = "Welcome to wechat world!"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }else{ echo "Input something..."; } }else { echo ""; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } } ?>api

注意要採用專業的軟件。設置編碼爲UTF-8。同一時候壓縮爲zip的文件,才幹夠上傳哦,不用使用記事本哦
上傳成功的話,點擊編輯代碼。是可以看到咱們的代碼的哦


打開那個連接:可以看到咱們搭建的網頁哦

相關文章
相關標籤/搜索