2014年巴西世界杯(英語:2014 FIFA World Cup)是第20屆世界杯足球賽。比賽於2014年6月12日至7月13日在南美洲國家巴西境內12座城市中的12座球場內舉行。這是繼1950年巴西世界杯之後世界杯第二次在巴西舉行,也是繼1978年阿根廷世界杯之後世界杯第五次在南美洲舉行。
巴西世界杯共有32支球隊參賽。除去東道主巴西自動獲得參賽資格以外,其他31個國家需通過參加2011年6月開始的預選賽獲得參賽資格。巴西世界杯期間,總共在巴西境內舉辦共計64場比賽角逐出冠軍。同時,巴西世界杯是首屆運用門線技術的世界杯。
<?php /* 方倍工作室 CopyRight 2014 All Rights Reserved */ define("TOKEN", "weixin"); $wechatObj = new wechatCallbackapiTest(); if (!isset($_GET['echostr'])) { $wechatObj->responseMsg(); }else{ $wechatObj->valid(); } class wechatCallbackapiTest { public function valid() { $echoStr = $_GET["echostr"]; $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){ echo $echoStr; exit; } } public function responseMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)){ $this->logger("R ".$postStr); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $RX_TYPE = trim($postObj->MsgType); switch ($RX_TYPE) { case "event": $result = $this->receiveEvent($postObj); break; case "text": $result = $this->receiveText($postObj); break; } $this->logger("T ".$result); echo $result; }else { echo ""; exit; } } private function receiveEvent($object) { $content = ""; switch ($object->Event) { case "subscribe": $content = array(); $content[] = array("Title" =>"2014年巴西世界杯賽程","Description" =>"", "PicUrl" =>"http://images.cnitblog.com/i/340216/201406/111304544204656.jpg", "Url" =>"http://url.cn/RInu1v"); break; } if(is_array($content)){ $result = $this->transmitNews($object, $content); }else{ $result = $this->transmitText($object, $content); } return $result; } private function receiveText($object) { $keyword = trim($object->Content); if (strstr($keyword, "世界杯") || strstr($keyword, "足球")){ $content = array(); $content[] = array("Title" =>"2014年巴西世界杯賽程","Description" =>"", "PicUrl" =>"http://images.cnitblog.com/i/340216/201406/111304544204656.jpg", "Url" =>"http://url.cn/RInu1v"); }else{ $content = date("Y-m-d H:i:s",time())."\n技術支持 方倍工作室"; } if(is_array($content)){ $result = $this->transmitNews($object, $content); }else{ $result = $this->transmitText($object, $content); } return $result; } private function transmitText($object, $content) { $textTpl = "<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[%s]]></Content> </xml>"; $result = sprintf($textTpl, $object->FromUserName, $object->ToUserName, time(), $content); return $result; } private function transmitNews($object, $arr_item) { if(!is_array($arr_item)) return; $itemTpl = " <item> <Title><![CDATA[%s]]></Title> <Description><![CDATA[%s]]></Description> <PicUrl><![CDATA[%s]]></PicUrl> <Url><![CDATA[%s]]></Url> </item> "; $item_str = ""; foreach ($arr_item as $item) $item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']); $newsTpl = "<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[news]]></MsgType> <Content><![CDATA[]]></Content> <ArticleCount>%s</ArticleCount> <Articles> $item_str</Articles> </xml>"; $result = sprintf($newsTpl, $object->FromUserName, $object->ToUserName, time(), count($arr_item)); return $result; } private function logger($log_content) { if(isset($_SERVER['HTTP_BAE_ENV_APPID'])){ //BAE require_once "BaeLog.class.php"; $logger = BaeLog::getInstance(); $logger ->logDebug($log_content); }else if(isset($_SERVER['HTTP_APPNAME'])){ //SAE sae_set_display_errors(false); sae_debug($log_content); sae_set_display_errors(true); }else if($_SERVER['REMOTE_ADDR'] != "127.0.0.1"){ //LOCAL $max_size = 10000; $log_filename = "log.xml"; if(file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)){unlink($log_filename);} file_put_contents($log_filename, date('H:i:s')." ".$log_content."\r\n", FILE_APPEND); } } } ?>
效果圖
====================================================================
方倍工作室微信公眾平台賬號關注方法:
1. 微信通訊錄-添加朋友-查找公眾號-搜索“方倍工作室”
2. 微信通訊錄-添加朋友-搜號碼-輸入“pondbaystudio”
3. 使用微信掃描下面的二維碼