In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The knowledge of this article "how WeChat Mini Programs develops the function of moments" is not quite understood by most people, so the editor summarizes the following contents for you. The content is detailed, the steps are clear, and it has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how WeChat Mini Programs develops the function of moments".
First, the analysis of development function: 1. Each piece of content is displayed in a list.
two。 Click to show the details of the content
3. Comment function
Second, the database is set up here with the list and details, we use one table to implement, and the comments use the second table. Total 2 tables
1.post table
We can directly import a JSON like this, but because the information on the front page is operated in this way, the data are all exactly the same. This time, we use cloud functions to collect data to the database on a regular basis.
two。 Collect data
Data structure address:
Var url = 'https://apiquan.ithome.com/api/post?categoryid=0&type=0&orderTime=1526981875455&visistCount=&pageLength='
If you import manually, you can import this data structure:
{"id": 266716, "t": "can ordinary Unicom card be transferred to rice noodle card?" , "c": "[chats]", "cn": "talk freely", "uid": 100058, "un": "China Rocket Army", "rn": "Nokia Lumia 930,930," pt": "/ Date (1527057744773) /", "rt": "/ Date (1527060538403) /", "vc": 0, "rc": 17, "IC": false, "IH": false, "ot": "/ Date (- 6213556800000) /"} Cloud function to obtain URL data code:
Function onRequest (request, response, modules) {var http = modules.oHttp;var url = 'https://apiquan.ithome.com/api/post?categoryid=0&type=0&orderTime=1526981875455&visistCount=&pageLength='http(url, function (error, res, body) {response.end (body);});} Click the test to see the result
In this way, you can get the target URL data. How to insert into the database, see the following code:
Db.insert ({"table": "XXX", / / table name "data": {"a": "XXXX", "b": "XXXX"} / / data to be updated in the format of JSON}, function (err,data) {/ / callback function}). If you insert a single row of data in batch, you can use the following code:
Function onRequest (request, response, modules) {var http = modules.oHttp;var db = modules.oData;var url = 'https://apiquan.ithome.com/api/post?categoryid=0&type=0&orderTime=1526981875455&visistCount=&pageLength='http(url, function (error, res, body) {/ / result is converted to object type var results = JSON.parse (body); var arr = [] / update data for (var i in results) {newdata = {"method": "post", "path": "/ 1/classes/post", "body": results [I]}; arr.push (newdata)} / / get array objects var bat = modules.oBatch;// batch operation bat.exec ({"data": {"requests": arr}}, function (err, data) {/ / callback function response.end (data); return;}) Response.end (JSON.stringify (results.length));});} click test
The above is about the content of this article "how to develop the function of moments by WeChat Mini Programs". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.