Home > Backend Development > PHP Tutorial > WeChat public platform development (103) CET-4 and CET-6 score query, 103 score query_PHP tutorial

WeChat public platform development (103) CET-4 and CET-6 score query, 103 score query_PHP tutorial

WBOY
Release: 2016-07-13 10:20:43
Original
893 people have browsed it

WeChat public platform development (103) CET-4 and CET-6 score query, 103 score query

National College English CET-4 and CET-6 exam results in June 2014 in August 2014 Published at 9:00 am on the 20th

We provide WeChat query method

1. Follow the WeChat public account

2. Reply to “Level 4 or 6”

3. Enter your name and admission ticket number

4. Return query results

Code implementation

<span>  1</span> <?<span>php
</span><span>  2</span> <span>/*</span>
<span>  3</span> <span>    方倍工作室 2014年6月全国大学英语四六级考试成绩查询
</span><span>  4</span> <span>    CopyRight 2014 All Rights Reserved
</span><span>  5</span> <span>*/</span>
<span>  6</span> 
<span>  7</span> <span>define</span>("TOKEN", "weixin"<span>);
</span><span>  8</span> 
<span>  9</span> <span>$wechatObj</span> = <span>new</span><span> wechatCallbackapiTest();
</span><span> 10</span> <span>if</span> (!<span>isset</span>(<span>$_GET</span>['echostr'<span>])) {
</span><span> 11</span>     <span>$wechatObj</span>-><span>responseMsg();
</span><span> 12</span> }<span>else</span><span>{
</span><span> 13</span>     <span>$wechatObj</span>-><span>valid();
</span><span> 14</span> <span>}
</span><span> 15</span> 
<span> 16</span> <span>class</span><span> wechatCallbackapiTest
</span><span> 17</span> <span>{
</span><span> 18</span>     <span>public</span> <span>function</span><span> valid()
</span><span> 19</span> <span>    {
</span><span> 20</span>         <span>$echoStr</span> = <span>$_GET</span>["echostr"<span>];
</span><span> 21</span>         <span>$signature</span> = <span>$_GET</span>["signature"<span>];
</span><span> 22</span>         <span>$timestamp</span> = <span>$_GET</span>["timestamp"<span>];
</span><span> 23</span>         <span>$nonce</span> = <span>$_GET</span>["nonce"<span>];
</span><span> 24</span>         <span>$token</span> =<span> TOKEN;
</span><span> 25</span>         <span>$tmpArr</span> = <span>array</span>(<span>$token</span>, <span>$timestamp</span>, <span>$nonce</span><span>);
</span><span> 26</span>         <span>sort</span>(<span>$tmpArr</span><span>);
</span><span> 27</span>         <span>$tmpStr</span> = <span>implode</span>(<span>$tmpArr</span><span>);
</span><span> 28</span>         <span>$tmpStr</span> = <span>sha1</span>(<span>$tmpStr</span><span>);
</span><span> 29</span>         <span>if</span>(<span>$tmpStr</span> == <span>$signature</span><span>){
</span><span> 30</span>             <span>echo</span> <span>$echoStr</span><span>;
</span><span> 31</span>             <span>exit</span><span>;
</span><span> 32</span> <span>        }
</span><span> 33</span> <span>    }
</span><span> 34</span> 
<span> 35</span>     <span>public</span> <span>function</span><span> responseMsg()
</span><span> 36</span> <span>    {
</span><span> 37</span>         <span>$postStr</span> = <span>$GLOBALS</span>["HTTP_RAW_POST_DATA"<span>];
</span><span> 38</span>         <span>if</span> (!<span>empty</span>(<span>$postStr</span><span>)){
</span><span> 39</span>             <span>$this</span>->logger("R ".<span>$postStr</span><span>);
</span><span> 40</span>             <span>$postObj</span> = <span>simplexml_load_string</span>(<span>$postStr</span>, 'SimpleXMLElement',<span> LIBXML_NOCDATA);
</span><span> 41</span>             <span>$RX_TYPE</span> = <span>trim</span>(<span>$postObj</span>-><span>MsgType);
</span><span> 42</span> 
<span> 43</span>             <span>switch</span> (<span>$RX_TYPE</span><span>)
</span><span> 44</span> <span>            {
</span><span> 45</span>                 <span>case</span> "event":
<span> 46</span>                     <span>$result</span> = <span>$this</span>->receiveEvent(<span>$postObj</span><span>);
</span><span> 47</span>                     <span>break</span><span>;
</span><span> 48</span>                 <span>case</span> "text":
<span> 49</span>                     <span>$result</span> = <span>$this</span>->receiveText(<span>$postObj</span><span>);
</span><span> 50</span>                     <span>break</span><span>;
</span><span> 51</span> <span>            }
</span><span> 52</span>             <span>$this</span>->logger("T ".<span>$result</span><span>);
</span><span> 53</span>             <span>echo</span> <span>$result</span><span>;
</span><span> 54</span>         }<span>else</span><span> {
</span><span> 55</span>             <span>echo</span> ""<span>;
</span><span> 56</span>             <span>exit</span><span>;
</span><span> 57</span> <span>        }
</span><span> 58</span> <span>    }
</span><span> 59</span>     
<span> 60</span>     <span>private</span> <span>function</span> receiveEvent(<span>$object</span><span>)
</span><span> 61</span> <span>    {
</span><span> 62</span>         <span>$content</span> = ""<span>;
</span><span> 63</span>         <span>switch</span> (<span>$object</span>-><span>Event)
</span><span> 64</span> <span>        {
</span><span> 65</span>             <span>case</span> "subscribe":
<span> 66</span>                 <span>$content</span> = <span>array</span><span>();
</span><span> 67</span>                 <span>$content</span>[] = <span>array</span>("Title" =>"2014年6月全国大学英语四六级考试成绩查询","Description" =>"", "PicUrl" =>"http://365jia.cn/uploads/13/0301/5130c2ff93618.jpg", "Url" =>"http://apix.sinaapp.com/cet/index.php?openid=".<span>$object</span>-><span>FromUserName);
</span><span> 68</span>                 <span>break</span><span>;
</span><span> 69</span> <span>        }
</span><span> 70</span>         <span>if</span>(<span>is_array</span>(<span>$content</span><span>)){
</span><span> 71</span>             <span>$result</span> = <span>$this</span>->transmitNews(<span>$object</span>, <span>$content</span><span>);
</span><span> 72</span>         }<span>else</span><span>{
</span><span> 73</span>             <span>$result</span> = <span>$this</span>->transmitText(<span>$object</span>, <span>$content</span><span>);
</span><span> 74</span> <span>        }
</span><span> 75</span>         <span>return</span> <span>$result</span><span>;
</span><span> 76</span> <span>    }
</span><span> 77</span>   
<span> 78</span>     <span>private</span> <span>function</span> receiveText(<span>$object</span><span>)
</span><span> 79</span> <span>    {
</span><span> 80</span>         <span>$keyword</span> = <span>trim</span>(<span>$object</span>-><span>Content);
</span><span> 81</span>         <span>if</span> (<span>strstr</span>(<span>$keyword</span>, "四六级") || <span>strstr</span>(<span>$keyword</span>, "英语"<span>)){
</span><span> 82</span>             <span>$content</span> = <span>array</span><span>();
</span><span> 83</span>             <span>$content</span>[] = <span>array</span>("Title" =>"2014年6月全国大学英语四六级考试成绩查询","Description" =>"", "PicUrl" =>"http://365jia.cn/uploads/13/0301/5130c2ff93618.jpg", "Url" =>"http://apix.sinaapp.com/cet/index.php?openid=".<span>$object</span>-><span>FromUserName);
</span><span> 84</span>         }<span>else</span><span>{
</span><span> 85</span>             <span>$content</span> = <span>date</span>("Y-m-d H:i:s",<span>time</span>())."\n技术支持 方倍工作室"<span>;
</span><span> 86</span> <span>        }
</span><span> 87</span>         <span>if</span>(<span>is_array</span>(<span>$content</span><span>)){
</span><span> 88</span>             <span>$result</span> = <span>$this</span>->transmitNews(<span>$object</span>, <span>$content</span><span>);
</span><span> 89</span>         }<span>else</span><span>{
</span><span> 90</span>             <span>$result</span> = <span>$this</span>->transmitText(<span>$object</span>, <span>$content</span><span>);
</span><span> 91</span> <span>        }
</span><span> 92</span>         <span>return</span> <span>$result</span><span>;
</span><span> 93</span> <span>    }
</span><span> 94</span> 
<span> 95</span>     <span>private</span> <span>function</span> transmitText(<span>$object</span>, <span>$content</span><span>)
</span><span> 96</span> <span>    {
</span><span> 97</span>         <span>$textTpl</span> = "<span><xml>
</span><span> 98</span> <span><ToUserName><![CDATA[%s]]></ToUserName>
</span><span> 99</span> <span><FromUserName><![CDATA[%s]]></FromUserName>
</span><span>100</span> <span><CreateTime>%s</CreateTime>
</span><span>101</span> <span><MsgType><![CDATA[text]]></MsgType>
</span><span>102</span> <span><Content><![CDATA[%s]]></Content>
</span><span>103</span> </xml>"<span>;
</span><span>104</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>105</span>         <span>return</span> <span>$result</span><span>;
</span><span>106</span> <span>    }
</span><span>107</span> 
<span>108</span>     <span>private</span> <span>function</span> transmitNews(<span>$object</span>, <span>$arr_item</span><span>)
</span><span>109</span> <span>    {
</span><span>110</span>         <span>if</span>(!<span>is_array</span>(<span>$arr_item</span><span>))
</span><span>111</span>             <span>return</span><span>;
</span><span>112</span> 
<span>113</span>         <span>$itemTpl</span> = "<span>    <item>
</span><span>114</span> <span>        <Title><![CDATA[%s]]></Title>
</span><span>115</span> <span>        <Description><![CDATA[%s]]></Description>
</span><span>116</span> <span>        <PicUrl><![CDATA[%s]]></PicUrl>
</span><span>117</span> <span>        <Url><![CDATA[%s]]></Url>
</span><span>118</span> <span>    </item>
</span><span>119</span> "<span>;
</span><span>120</span>         <span>$item_str</span> = ""<span>;
</span><span>121</span>         <span>foreach</span> (<span>$arr_item</span> <span>as</span> <span>$item</span><span>)
</span><span>122</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>123</span> 
<span>124</span>         <span>$newsTpl</span> = "<span><xml>
</span><span>125</span> <span><ToUserName><![CDATA[%s]]></ToUserName>
</span><span>126</span> <span><FromUserName><![CDATA[%s]]></FromUserName>
</span><span>127</span> <span><CreateTime>%s</CreateTime>
</span><span>128</span> <span><MsgType><![CDATA[news]]></MsgType>
</span><span>129</span> <span><Content><![CDATA[]]></Content>
</span><span>130</span> <span><ArticleCount>%s</ArticleCount>
</span><span>131</span> <span><Articles>
</span><span>132</span> <span>$item_str</span><span></Articles>
</span><span>133</span> </xml>"<span>;
</span><span>134</span> 
<span>135</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>136</span>         <span>return</span> <span>$result</span><span>;
</span><span>137</span> <span>    }
</span><span>138</span> 
<span>139</span>     <span>private</span> <span>function</span> logger(<span>$log_content</span><span>)
</span><span>140</span> <span>    {
</span><span>141</span> <span>    }
</span><span>142</span> <span>}
</span><span>143</span> 
<span>144</span> 
<span>145</span> ?>
Copy after login

WeChat public platform development example

This book is available on JD.com or Dangdang. "WeChat Public Platform Application Development Practice" is written by Zhong Zhiyong, a senior software development engineer at Tencent and a pioneer in WeChat public platform application development. Its authoritativeness is unquestionable
A comprehensive introduction to WeChat public Various technologies required for platform application development, systematically interpreting the open API and various advanced functions of WeChat public platform, and gradually explaining the process, methods and techniques of WeChat public platform application development
Focusing on practical combat, not only presenting entertainment through 3 cases It not only provides a complete development process for type, application and game-type applications, but also implements a framework for rapid development of public platform applications, which can be used directly.

Can I click on the advanced functions of the WeChat public platform and the page does not exist?

Are you a newly registered account? If it is a new account, it may not be displayed because it has not been approved yet. If it's not a new account, clear the browser cache, or try another machine. There should be no other reason.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/866464.htmlTechArticleWeChat public platform development (103) CET-4 and CET-6 score inquiry, 103 score inquiry in June 2014 National College English Level 4 , CET-6 exam results will be released at 9:00 am on August 20, 2014. We provide WeChat...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template