About this little program

Making: github.com/DowneyL/di…. ‘

This small program is for a company’s own product requirements, and the product is Discuz (I know no one use, don’t make fun of it), version is X3.2, or GBK coding!

I found a basic version on the Internet (shamefully not all written by myself), fixed some bugs, added some functions, also cut some functions, compatible with the GBK version of Discuz, and simply designed a small program style. The product is basically formed.

I want to record it on a platform. If I meet the right person, MAYBE I can give him some harvest. 0.0 \

I harvest

  1. I have some understanding of API development (just happened to be Summer’s new book, I will buy it and read it after more)
  2. Wechat public number development (native PHP development wechat public number, and super-god Easywechat) also successfully let the company’s forum associated with the public number, to achieve the public number, to receive the forum money red envelope.
  3. Wechat small program development (official documents, the source of the small program under development, have given me a lot of inspiration)
  4. HTTP to HTTPS
  5. Rich text parsing on applets (an excellent open source project: wxParse- wechat applets rich text parsing component) is used to parse your forum posts. Bold text, colored text, images, etc., can be displayed in the applets.
  6. Flex Layout tutorial: Syntax tutorial and Flex Layout Tutorial: Examples
  7. Two UI components weui and Zanui
  8. .

Some details

The following functions need to be recorded

The first section

  1. file_get_content()The function, which may not be available on the forum, is already ininc.phpFile that implements the same function
Get_url_content () function. function get_url_content($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); # curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); if (! curl_exec($ch)) { error_log(curl_error($ch)); $data = ''; } else { $data = curl_multi_getcontent($ch); } curl_close($ch); return $data; }Copy the code
  1. Since the overall format of the forum is GBK, and the interaction with wechat server must be UTF-8 encoding, part of the interface coding has been optimized.

In the case of output, there is the array_iconv() function under error.php to encode the output array.

static function array_iconv($str, $in_charset = "UTF-8", $out_charset = CHARSET) { if (is_array($str)) { foreach ($str as $k => $v) { $str[$k] = WmApiError::array_iconv($v, $in_charset, $out_charset); } return $str; } else { if (is_string($str)) { // return iconv('UTF-8', 'GBK//IGNORE', $str); return mb_convert_encoding($str, $out_charset, $in_charset); } else { return $str; }}Copy the code

In the case of acceptance, there is the getDataForCharset() function under inc.php to integrate the acceptance code.

function getDataForCharset($data) { return (CHARSET ! = 'UTF-8') ? dhtmlspecialchars(WmApiError::array_iconv($data)) : dhtmlspecialchars($data); }Copy the code
  1. Closed the wechat login function.
  2. “Message” was added to get a post.
  3. Some other details have been optimized.

In the second quarter

What wxParse does

  1. When outputting the post, decode the Discuz Code, at the same time, get the picture attachment, as well as the expression picture.
  2. When receiving, parse text for bold, highlighting, italics, font, etc. Leave the post output as is.
  3. The above functions are highlighted in the wmapi/get_post_detail.php and wmapi/get_self_post.php scripts.

In the third quarter

  1. Partial access to the data of the applets is as followsget_url_content()Part isfile_get_content()(The production environment may be so weird due to setup problems, please look at it in combination with your own server)
  2. Home page Added loading status (loading… No more… No data yet…)
  3. Group post, the group name cannot be displayed
  4. When the applet passes the Chinese string to the server, firstencodeURI()Go to the forum serverurldecode()Finally UTF8 -> GBK transcoding, of course, is necessary in the case.

Basic display




By: August 5th



Original address:Discuz! + micro channel small program – practical tutorial – small program community – micro channel small program – micro channel small program development community – small program development forum – micro channel small program alliance



Statement: this article is from the network, copyright belongs to the author, does not represent the views of this column, any questions please contact me, thank you!