Home Backend Development PHP Tutorial WeChat public platform development (95) 2014 World Cup schedule_PHP tutorial

WeChat public platform development (95) 2014 World Cup schedule_PHP tutorial

Jul 13, 2016 am 10:28 AM
Development tutorial WeChat development

The 2014 Brazil World Cup (English: 2014 FIFA World Cup) is the 20th World Cup. The competition was held from June 12 to July 13, 2014, in 12 stadiums in 12 cities in Brazil, a South American country. This is the second time the World Cup has been held in Brazil, following the 1950 World Cup in Brazil, and the fifth time the World Cup has been held in South America, following the 1978 World Cup in Argentina.

There are 32 teams participating in the Brazil World Cup. Except for the host Brazil, which automatically qualifies, the other 31 countries need to qualify by participating in the qualifiers starting in June 2011. During the Brazil World Cup, a total of 64 games were held in Brazil to compete for the championship. At the same time, the Brazil World Cup is the first World Cup to use goal-line technology.

<?<span>php
</span><span>/*</span><span>
    方倍工作室
    CopyRight 2014 All Rights Reserved
</span><span>*/</span>

<span>define</span>("TOKEN", "weixin"<span>);

</span><span>$wechatObj</span> = <span>new</span><span> wechatCallbackapiTest();
</span><span>if</span> (!<span>isset</span>(<span>$_GET</span>['echostr'<span>])) {
    </span><span>$wechatObj</span>-><span>responseMsg();
}</span><span>else</span><span>{
    </span><span>$wechatObj</span>-><span>valid();
}

</span><span>class</span><span> wechatCallbackapiTest
{
    </span><span>public</span> <span>function</span><span> valid()
    {
        </span><span>$echoStr</span> = <span>$_GET</span>["echostr"<span>];
        </span><span>$signature</span> = <span>$_GET</span>["signature"<span>];
        </span><span>$timestamp</span> = <span>$_GET</span>["timestamp"<span>];
        </span><span>$nonce</span> = <span>$_GET</span>["nonce"<span>];
        </span><span>$token</span> =<span> TOKEN;
        </span><span>$tmpArr</span> = <span>array</span>(<span>$token</span>, <span>$timestamp</span>, <span>$nonce</span><span>);
        </span><span>sort</span>(<span>$tmpArr</span><span>);
        </span><span>$tmpStr</span> = <span>implode</span>(<span>$tmpArr</span><span>);
        </span><span>$tmpStr</span> = <span>sha1</span>(<span>$tmpStr</span><span>);
        </span><span>if</span>(<span>$tmpStr</span> == <span>$signature</span><span>){
            </span><span>echo</span> <span>$echoStr</span><span>;
            </span><span>exit</span><span>;
        }
    }

    </span><span>public</span> <span>function</span><span> responseMsg()
    {
        </span><span>$postStr</span> = <span>$GLOBALS</span>["HTTP_RAW_POST_DATA"<span>];
        </span><span>if</span> (!<span>empty</span>(<span>$postStr</span><span>)){
            </span><span>$this</span>->logger("R ".<span>$postStr</span><span>);
            </span><span>$postObj</span> = <span>simplexml_load_string</span>(<span>$postStr</span>, 'SimpleXMLElement',<span> LIBXML_NOCDATA);
            </span><span>$RX_TYPE</span> = <span>trim</span>(<span>$postObj</span>-><span>MsgType);

            </span><span>switch</span> (<span>$RX_TYPE</span><span>)
            {
                </span><span>case</span> "event":
                    <span>$result</span> = <span>$this</span>->receiveEvent(<span>$postObj</span><span>);
                    </span><span>break</span><span>;
                </span><span>case</span> "text":
                    <span>$result</span> = <span>$this</span>->receiveText(<span>$postObj</span><span>);
                    </span><span>break</span><span>;
            }
            </span><span>$this</span>->logger("T ".<span>$result</span><span>);
            </span><span>echo</span> <span>$result</span><span>;
        }</span><span>else</span><span> {
            </span><span>echo</span> ""<span>;
            </span><span>exit</span><span>;
        }
    }
    
    </span><span>private</span> <span>function</span> receiveEvent(<span>$object</span><span>)
    {
        </span><span>$content</span> = ""<span>;
        </span><span>switch</span> (<span>$object</span>-><span>Event)
        {
            </span><span>case</span> "subscribe":
                <span>$content</span> = <span>array</span><span>();
                </span><span>$content</span>[] = <span>array</span>("Title" =>"2014年巴西世界杯赛程","Description" =>"", "PicUrl" =>"http://images.cnitblog.com/i/340216/201406/111304544204656.jpg", "Url" =>"http://url.cn/RInu1v"<span>);
                </span><span>break</span><span>;
        }
        </span><span>if</span>(<span>is_array</span>(<span>$content</span><span>)){
            </span><span>$result</span> = <span>$this</span>->transmitNews(<span>$object</span>, <span>$content</span><span>);
        }</span><span>else</span><span>{
            </span><span>$result</span> = <span>$this</span>->transmitText(<span>$object</span>, <span>$content</span><span>);
        }
        </span><span>return</span> <span>$result</span><span>;
    }
  
    </span><span>private</span> <span>function</span> receiveText(<span>$object</span><span>)
    {
        </span><span>$keyword</span> = <span>trim</span>(<span>$object</span>-><span>Content);
        </span><span>if</span> (<span>strstr</span>(<span>$keyword</span>, "世界杯") || <span>strstr</span>(<span>$keyword</span>, "足球"<span>)){
            </span><span>$content</span> = <span>array</span><span>();
            </span><span>$content</span>[] = <span>array</span>("Title" =>"2014年巴西世界杯赛程","Description" =>"", "PicUrl" =>"http://images.cnitblog.com/i/340216/201406/111304544204656.jpg", "Url" =>"http://url.cn/RInu1v"<span>);
        }</span><span>else</span><span>{
            </span><span>$content</span> = <span>date</span>("Y-m-d H:i:s",<span>time</span>())."\n技术支持 方倍工作室"<span>;
        }
        </span><span>if</span>(<span>is_array</span>(<span>$content</span><span>)){
            </span><span>$result</span> = <span>$this</span>->transmitNews(<span>$object</span>, <span>$content</span><span>);
        }</span><span>else</span><span>{
            </span><span>$result</span> = <span>$this</span>->transmitText(<span>$object</span>, <span>$content</span><span>);
        }
        </span><span>return</span> <span>$result</span><span>;
    }

    </span><span>private</span> <span>function</span> transmitText(<span>$object</span>, <span>$content</span><span>)
    {
        </span><span>$textTpl</span> = "<span><xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml></span>"<span>;
        </span><span>$result</span> = <span>sprintf</span>(<span>$textTpl</span>, <span>$object</span>->FromUserName, <span>$object</span>->ToUserName, <span>time</span>(), <span>$content</span><span>);
        </span><span>return</span> <span>$result</span><span>;
    }

    </span><span>private</span> <span>function</span> transmitNews(<span>$object</span>, <span>$arr_item</span><span>)
    {
        </span><span>if</span>(!<span>is_array</span>(<span>$arr_item</span><span>))
            </span><span>return</span><span>;

        </span><span>$itemTpl</span> = "<span>    <item>
        <Title><![CDATA[%s]]></Title>
        <Description><![CDATA[%s]]></Description>
        <PicUrl><![CDATA[%s]]></PicUrl>
        <Url><![CDATA[%s]]></Url>
    </item>
</span>"<span>;
        </span><span>$item_str</span> = ""<span>;
        </span><span>foreach</span> (<span>$arr_item</span> <span>as</span> <span>$item</span><span>)
            </span><span>$item_str</span> .= <span>sprintf</span>(<span>$itemTpl</span>, <span>$item</span>['Title'], <span>$item</span>['Description'], <span>$item</span>['PicUrl'], <span>$item</span>['Url'<span>]);

        </span><span>$newsTpl</span> = "<span><xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<Content><![CDATA[]]></Content>
<ArticleCount>%s</ArticleCount>
<Articles>
</span><span>$item_str</span><span></Articles>
</xml></span>"<span>;

        </span><span>$result</span> = <span>sprintf</span>(<span>$newsTpl</span>, <span>$object</span>->FromUserName, <span>$object</span>->ToUserName, <span>time</span>(), <span>count</span>(<span>$arr_item</span><span>));
        </span><span>return</span> <span>$result</span><span>;
    }

    </span><span>private</span> <span>function</span> logger(<span>$log_content</span><span>)
    {
        </span><span>if</span>(<span>isset</span>(<span>$_SERVER</span>['HTTP_BAE_ENV_APPID'])){   <span>//</span><span>BAE</span>
            <span>require_once</span> "BaeLog.class.php"<span>;
            </span><span>$logger</span> = BaeLog::<span>getInstance();
            </span><span>$logger</span> ->logDebug(<span>$log_content</span><span>);
        }</span><span>else</span> <span>if</span>(<span>isset</span>(<span>$_SERVER</span>['HTTP_APPNAME'])){   <span>//</span><span>SAE</span>
            sae_set_display_errors(<span>false</span><span>);
            sae_debug(</span><span>$log_content</span><span>);
            sae_set_display_errors(</span><span>true</span><span>);
        }</span><span>else</span> <span>if</span>(<span>$_SERVER</span>['REMOTE_ADDR'] != "127.0.0.1"){ <span>//</span><span>LOCAL</span>
            <span>$max_size</span> = 10000<span>;
            </span><span>$log_filename</span> = "log.xml"<span>;
            </span><span>if</span>(<span>file_exists</span>(<span>$log_filename</span>) and (<span>abs</span>(<span>filesize</span>(<span>$log_filename</span>)) > <span>$max_size</span>)){<span>unlink</span>(<span>$log_filename</span><span>);}
            </span><span>file_put_contents</span>(<span>$log_filename</span>, <span>date</span>('H:i:s')." ".<span>$log_content</span>."\r\n",<span> FILE_APPEND);
        }
    }
}


</span>?>
Copy after login

Rendering

================================================== =====================

How to follow Fangbei Studio’s WeChat public platform account:
1. WeChat address book-add friend-search public account-search for “Fangbei Studio”
2. WeChat address book-add friend-search Number - enter "pondbaystudio"
3. Use WeChat to scan the QR code below

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/781921.htmlTechArticleThe 2014 Brazil World Cup (English: 2014 FIFA World Cup) is the 20th World Cup. The competition was held from June 12 to July 13, 2014 at 12 courses in 12 cities in Brazil, a South American country...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP WeChat development: How to implement message encryption and decryption PHP WeChat development: How to implement message encryption and decryption May 13, 2023 am 11:40 AM

PHP is an open source scripting language that is widely used in web development and server-side programming, especially in WeChat development. Today, more and more companies and developers are starting to use PHP for WeChat development because it has become a truly easy-to-learn and easy-to-use development language. In WeChat development, message encryption and decryption are a very important issue because they involve data security. For messages without encryption and decryption methods, hackers can easily obtain the data, posing a threat to users.

PHP WeChat development: How to implement customer service chat window management PHP WeChat development: How to implement customer service chat window management May 13, 2023 pm 05:51 PM

WeChat is currently one of the social platforms with the largest user base in the world. With the popularity of mobile Internet, more and more companies are beginning to realize the importance of WeChat marketing. When conducting WeChat marketing, customer service is a crucial part. In order to better manage the customer service chat window, we can use PHP language for WeChat development. 1. Introduction to PHP WeChat development PHP is an open source server-side scripting language that is widely used in the field of Web development. Combined with the development interface provided by WeChat public platform, we can use PHP language to conduct WeChat

PHP WeChat development: How to implement user tag management PHP WeChat development: How to implement user tag management May 13, 2023 pm 04:31 PM

In the development of WeChat public accounts, user tag management is a very important function, which allows developers to better understand and manage their users. This article will introduce how to use PHP to implement the WeChat user tag management function. 1. Obtain the openid of the WeChat user. Before using the WeChat user tag management function, we first need to obtain the user's openid. In the development of WeChat public accounts, it is a common practice to obtain openid through user authorization. After the user authorization is completed, we can obtain the user through the following code

Enterprise WeChat interface docking and PHP approval application development tutorial Enterprise WeChat interface docking and PHP approval application development tutorial Jul 05, 2023 pm 05:45 PM

Enterprise WeChat interface docking and PHP approval application development tutorial Enterprise WeChat is an enterprise communication tool launched by Tencent, which provides powerful enterprise-level functions, such as organizational structure management, enterprise application management, message and address book synchronization, etc. Enterprise WeChat opens a wealth of interfaces for developers to connect and develop applications, providing more personalized and customized enterprise-level applications. This article will focus on the docking of the enterprise WeChat interface and the development of PHP approval applications. The following are detailed steps and code examples: Step 1: Create an enterprise WeChat application and obtain

Using PHP to develop WeChat mass messaging tools Using PHP to develop WeChat mass messaging tools May 13, 2023 pm 05:00 PM

With the popularity of WeChat, more and more companies are beginning to use it as a marketing tool. The WeChat group messaging function is one of the important means for enterprises to conduct WeChat marketing. However, if you only rely on manual sending, it is an extremely time-consuming and laborious task for marketers. Therefore, it is particularly important to develop a WeChat mass messaging tool. This article will introduce how to use PHP to develop WeChat mass messaging tools. 1. Preparation work To develop WeChat mass messaging tools, we need to master the following technical points: Basic knowledge of PHP WeChat public platform development Development tools: Sub

How to use PHP for WeChat development? How to use PHP for WeChat development? May 21, 2023 am 08:37 AM

With the development of the Internet and mobile smart devices, WeChat has become an indispensable part of the social and marketing fields. In this increasingly digital era, how to use PHP for WeChat development has become the focus of many developers. This article mainly introduces the relevant knowledge points on how to use PHP for WeChat development, as well as some of the tips and precautions. 1. Development environment preparation Before developing WeChat, you first need to prepare the corresponding development environment. Specifically, you need to install the PHP operating environment and the WeChat public platform

ThinkPHP6 WeChat Development Guide: Quickly build WeChat public account applications ThinkPHP6 WeChat Development Guide: Quickly build WeChat public account applications Aug 26, 2023 pm 11:55 PM

ThinkPHP6 WeChat Development Guide: Quickly Build WeChat Public Account Application Introduction: As an important social media platform, WeChat public account provides great opportunities for individuals and enterprises in marketing, information dissemination and other aspects. In this article, we will introduce how to use ThinkPHP6 to quickly build a WeChat public account application, and provide some commonly used code examples. Environment preparation Before starting development, we first need to prepare the following environment: PHP7 or above version ThinkPHP6 framework WeChat public account

PHP WeChat development: How to implement group message sending records PHP WeChat development: How to implement group message sending records May 13, 2023 pm 04:31 PM

As WeChat becomes an increasingly important communication tool in people's lives, its agile messaging function is quickly favored by a large number of enterprises and individuals. For enterprises, developing WeChat into a marketing platform has become a trend, and the importance of WeChat development has gradually become more prominent. Among them, the group sending function is even more widely used. So, as a PHP programmer, how to implement group message sending records? The following will give you a brief introduction. 1. Understand the development knowledge related to WeChat public accounts. Before understanding how to implement group message sending records, I

See all articles