Home WeChat Applet WeChat Development Recommended video tutorial resources for WeChat public platform development by Chuanzhi and Dark Horse

Recommended video tutorial resources for WeChat public platform development by Chuanzhi and Dark Horse

Aug 31, 2017 am 11:52 AM
platform develop video

WeChat public platform is a new service platform that provides business services and user management capabilities to individuals, enterprises and organizations. The WeChat public platform mainly includes real-time communication, message sending and material management. Users can group and manage fans of public accounts and communicate in real time. They can also use advanced functions - editing mode and development mode to automatically reply to user information. "Chuangzhi and Dark Horse WeChat Public Platform Development Video Tutorial" is a WeChat public platform development video tutorial jointly produced by Chuanzhi Podcast and Dark Horse Programmers.

Recommended video tutorial resources for WeChat public platform development by Chuanzhi and Dark Horse

Course playback address: http://www.php.cn/course/320.html

The teacher’s teaching style:

The lectures are friendly and natural, unpretentious, not pretentious, nor deliberately exaggerated, but talk eloquently and carefully, and the relationship between teachers and students is In an atmosphere of equality, collaboration, and harmony, silent emotional exchanges are carried out, and the desire and exploration of knowledge are integrated into simple and real teaching situations. Students gain knowledge through quiet thinking and silent approval

The more difficult point in this video is the analysis of the WeChat API interface:

WeChat entrance binding, WeChat event processing, and all WeChat API operations are included in these files.
WeChat payment, WeChat red envelope, WeChat card and coupon, WeChat store.

1. index.php

<?php
include_once &#39;lib.inc.php&#39;;
  
$wcObj = new WeChat("YOUKUIYUAN");
$wcObj->wcValid();
Copy after login

2. WeChat entry class

<?php
/**
 * Description of wechat
 *
 * @author Administrator
 */
class WeChat extends WxApi{
  public $token = "";
  //put your code here
  public function __construct($token = "") {
    parent::__construct();
    $this->token = $token;
  }
  
  public function wcCheckSignature(){
    try{
      if (empty($this->token)) {
        throw new Exception(&#39;TOKEN is not defined!&#39;);
      }
        
      $signature = $_GET["signature"];
      $timestamp = $_GET["timestamp"];
      $nonce = $_GET["nonce"];
          
      $token = $this->token;
      $tmpArr = array($token, $timestamp, $nonce);
      // use SORT_STRING rule
      sort($tmpArr, SORT_STRING);
      $tmpStr = implode( $tmpArr );
      $tmpStr = sha1( $tmpStr );
  
      if( $tmpStr == $signature ){
          return true;
      }else{
          return false;
      }
    } 
    catch (Exception $e) {
      echo &#39;Message: &#39; .$e->getMessage();
    }
  }
    
  public function wcValid(){
    $echoStr = isset($_GET["echostr"]) && !empty($_GET["echostr"]) ? addslashes($_GET["echostr"]) : NULL;
    if(is_null($echoStr)){
      $this->wcMsg();
    }
    else{
      //valid signature , option
      if($this->wcCheckSignature()){
        echo $echoStr;
        exit;
      }
      else{
        exit();
      }
    }
  }
    
  public function wcMsg(){
    //get post data, May be due to the different environments
    $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) && !empty($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : "";
    if(!empty($postStr)){
      libxml_disable_entity_loader(true);
      $postObj = simplexml_load_string($postStr, &#39;SimpleXMLElement&#39;, LIBXML_NOCDATA);
      $this->zcLog(TRUE,$postObj);
        
      $fromUsername = $postObj->FromUserName;
      $toUsername = $postObj->ToUserName;
      $MsgType = $postObj->MsgType;
        
      if($MsgType == &#39;event&#39;){//执行事件相应
        $Event = $postObj->Event;
        switch ($Event) {
          case &#39;subscribe&#39;://关注
            break;
          case &#39;unsubscribe&#39;://取消关注
            break;
          case &#39;SCAN&#39;://扫描
            break;
          case &#39;LOCATION&#39;://地址
            break;
          case &#39;CLICK&#39;://点击时间
            break;
          case &#39;VIEW&#39;://跳转
            break;
          case &#39;card_pass_check&#39;://卡券审核通过
            break;
          case &#39;card_not_pass_check&#39;://卡券审核失败
            break;
          case &#39;user_get_card&#39;://用户领取卡券
            break;
          case &#39;user_del_card&#39;://用户删除卡券
            break;
          case &#39;user_view_card&#39;://用户浏览会员卡
            break;
          case &#39;user_consume_card&#39;://用户核销卡券
            break;
          case &#39;merchant_order&#39;://微小店用户下单付款
            break;
          default:
            break;
        }
      }
      else{
        switch ($MsgType) {
          case &#39;text&#39;://文本格式
            break;
          case &#39;image&#39;://图片格式
            break;
          case &#39;voice&#39;://声音
            break;
          case &#39;video&#39;://视频
            break;
          case &#39;shortvideo&#39;://小视频
            break;
          case &#39;location&#39;://上传地理位置
            break;
          case &#39;link&#39;://链接相应
            break;
          default:
            break;
        }        
      }
        
      ////////////////////////////////////////////////////////////////////
      $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;
    }
  }
    
  //日志LOG
  public function zcLog($errcode , $errmsg){
    $this->returnAy = array();
    $this->returnAy[&#39;errcode&#39;] = $errcode;
    $this->returnAy[&#39;errmsg&#39;] = $errmsg;
    $this->returnAy[&#39;errtime&#39;] = date("Y-m-d H:i:s",time());
    $logfile = fopen("logfile_".date("Ymd",time()).".txt", "a+");
    $txt = json_encode($this->returnAy)."\n";
    fwrite($logfile, $txt);
    fclose($logfile);
    //return $this->returnAy;
  }
    
}
Copy after login

The above is the detailed content of Recommended video tutorial resources for WeChat public platform development by Chuanzhi and Dark Horse. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Is it infringing to post other people's videos on Douyin? How does it edit videos without infringement? Is it infringing to post other people's videos on Douyin? How does it edit videos without infringement? Mar 21, 2024 pm 05:57 PM

With the rise of short video platforms, Douyin has become an indispensable part of everyone's daily life. On TikTok, we can see interesting videos from all over the world. Some people like to post other people’s videos, which raises a question: Is Douyin infringing upon posting other people’s videos? This article will discuss this issue and tell you how to edit videos without infringement and how to avoid infringement issues. 1. Is it infringing upon Douyin’s posting of other people’s videos? According to the provisions of my country's Copyright Law, unauthorized use of the copyright owner's works without the permission of the copyright owner is an infringement. Therefore, posting other people’s videos on Douyin without the permission of the original author or copyright owner is an infringement. 2. How to edit a video without infringement? 1. Use of public domain or licensed content: Public

How to make money from posting videos on Douyin? How can a newbie make money on Douyin? How to make money from posting videos on Douyin? How can a newbie make money on Douyin? Mar 21, 2024 pm 08:17 PM

Douyin, the national short video platform, not only allows us to enjoy a variety of interesting and novel short videos in our free time, but also gives us a stage to show ourselves and realize our values. So, how to make money by posting videos on Douyin? This article will answer this question in detail and help you make more money on TikTok. 1. How to make money from posting videos on Douyin? After posting a video and gaining a certain amount of views on Douyin, you will have the opportunity to participate in the advertising sharing plan. This income method is one of the most familiar to Douyin users and is also the main source of income for many creators. Douyin decides whether to provide advertising sharing opportunities based on various factors such as account weight, video content, and audience feedback. The TikTok platform allows viewers to support their favorite creators by sending gifts,

How to publish Xiaohongshu video works? What should I pay attention to when posting videos? How to publish Xiaohongshu video works? What should I pay attention to when posting videos? Mar 23, 2024 pm 08:50 PM

With the rise of short video platforms, Xiaohongshu has become a platform for many people to share their lives, express themselves, and gain traffic. On this platform, publishing video works is a very popular way of interaction. So, how to publish Xiaohongshu video works? 1. How to publish Xiaohongshu video works? First, make sure you have a video content ready to share. You can use your mobile phone or other camera equipment to shoot, but you need to pay attention to the image quality and sound clarity. 2. Edit the video: In order to make the work more attractive, you can edit the video. You can use professional video editing software, such as Douyin, Kuaishou, etc., to add filters, music, subtitles and other elements. 3. Choose a cover: The cover is the key to attracting users to click. Choose a clear and interesting picture as the cover to attract users to click on it.

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

How to post videos on Weibo without compressing the image quality_How to post videos on Weibo without compressing the image quality How to post videos on Weibo without compressing the image quality_How to post videos on Weibo without compressing the image quality Mar 30, 2024 pm 12:26 PM

1. First open Weibo on your mobile phone and click [Me] in the lower right corner (as shown in the picture). 2. Then click [Gear] in the upper right corner to open settings (as shown in the picture). 3. Then find and open [General Settings] (as shown in the picture). 4. Then enter the [Video Follow] option (as shown in the picture). 5. Then open the [Video Upload Resolution] setting (as shown in the picture). 6. Finally, select [Original Image Quality] to avoid compression (as shown in the picture).

Two solutions for sharing edge browser web videos with no sound Two solutions for sharing edge browser web videos with no sound Mar 14, 2024 pm 02:22 PM

Many users like to watch videos on the browser. If there is no sound when watching web videos on the edge browser, how to solve the problem? This problem is not difficult. Next, let me tell you how to fix the problem of no sound in edge browser web videos. There is no sound in edge browser web videos? Method 1: 1. First, check the top tab of the edge browser. 2. There is a "Sound Button" on the left side of the tab, make sure it is not muted. Method 2: 1. If it is confirmed that the sound is not muted, it may be a sound setting problem. 2. You can right-click the sound device in the lower right corner and select "Open Volume Synthesizer" 3. Open

Douyin 15 seconds is too short and I want to extend it. How can I extend it? How to make a video longer than 15 seconds? Douyin 15 seconds is too short and I want to extend it. How can I extend it? How to make a video longer than 15 seconds? Mar 22, 2024 pm 08:11 PM

With the popularity of Douyin, more and more people like to share their lives, talents and creativity on this platform. Douyin's 15-second limit makes many users feel that it is not enjoyable enough and hope to extend the video duration. So, how can you extend the video duration on Douyin? 1. Douyin 15 seconds is too short and I want to extend it. How can I extend it? 1. The most convenient way to shoot multiple videos and splice them is to record multiple 15-second videos, and then use the editing function of Douyin to combine them. When recording, make sure to leave some blank space at the beginning and end of each video for later splicing. The length of the spliced ​​video can be several minutes, but this may cause the video screen to switch too frequently, affecting the viewing experience. 2. Use Douyin special effects and stickers Douyin provides a series of special effects

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

See all articles