Talk about weiphp public platform development--1, add plugin

Source: Internet
Author: User
Tags response code

Last year began to contact the development of public platform based on weiphp, there is no time to tidy up.

Let's start with the first custom weiphp plugin: the Myhello development process.

1, plug-in creation. In the weiphp management background Click "Plug-in management, create plug-in" into the plugin creation page, fill in the plug-in's identity name, plug-in name, version, author, description and other information, tick "whether to enable after installation", "need to configure" two items, click "OK" to complete the creation of the plugin.

2, plug-in installation. Click "Install" in the Plugin management list to complete the installation of the plugin.

3, plug-in management. Return to the weiphp management foreground and you can see that the Myhello plugin has been successfully installed.

4. Overwrite the configuration file. In the weiphp addons directory, under the default generated Myhello plugins folder, overwrite the default generated config.php, adding the configuration items as shown below.

<?PHPreturn Array(    ' Title ' =Array(//Configure the key name in the form, this will be config[random]' title ' = ' Plugin name ',//the text of the form' Type ' = ' text ',//Types of Forms' Value ' = ' MyHello ',    ), ' cover ' =Array(//Configure the key name in the form, this will be config[random]' title ' = ' cover ',//the text of the form' Type ' = ' picture ',//Types of Forms' Value ' = ',    ), ' desc ' =Array(//Configure the key name in the form, this will be config[random]' Title ' = ' Description ',//the text of the form' Type ' = ' textarea ',//Types of Forms' Value ' = ' The first custom weiphp plugin ',    ), ' reply_type ' =Array(//Configure the key name in the form, this will be config[random]' Title ' = ' reply type ',//the text of the form' Type ' = ' Radio ',//Types of Forms' Options ' =Array(            ' 0 ' + ' text message ', ' 1 ' = ' ' single graphic message ',        ), ' value ' = ' 0 ',    ),); 

5. View the configuration items. You can see that the configuration file is responding properly.

6, Response. Write the response code for WeixinAddonModel.class.php.

<?php namespace Addons\myhello\model; UseHome\model\weixinmodel; /** * Model of Myhello*/classWeixinaddonmodelextendsweixinmodel{functionReply$DATAARR,$KEYWORDARR=Array()) {        $config= Getaddonconfig (' Myhello ');//get configuration parameters for the background plug-in//dump ($config);        $title=$config[' title ']; $desc=$congig[' Desc ']; $picurl=$config[' Cover ']?get_cover_url ($config[' Cover ']): '; $url= "Http://baidu.com"; $time=Date(' Y-m-d h:i:s ', Time()); /*$ans = "; foreach ($dataArr as $key = = $rs) {$ans. = "[". $key. "] = ". $rs."        \ n ";        } $ans. = "\ n"; foreach ($keywordArr as $key = = $rs) {$ans. = "[". $key. "] = ". $rs."        \ n "; }*/                if($config[' Reply_type ']==0)            $this->replytext ($title." \ n ".$time); Else{            $articles[0]=Array(                ' Title ' =$config[' title '], ' Description ' =$config[' Desc '], ' picurl ' =$picurl, ' Url ' = =$url            ); $this->replynews ($articles); }    }}

7. Edit the configuration item. In the Background configuration page fill in the configuration information, upload the cover picture, and click "OK" to submit the configuration item.

8, Test. When replying to "my plugins" or "MyHello" in, the reply is based on whether the type of reply selected in the configuration item is text message or single graphic message.

Welcome to my personal Test public account: fm1994~ Exchange study together.

Talk about weiphp public platform development--1, add plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.