How to retrieve kintone record information in WeChat

云朵
Release: 2017-11-29 14:13:27
Original
3038 people have browsed it

Summary

In recent years, more and more people are using WeChat official accounts, and our lifestyles have also undergone tremendous changes.

Kintone is naturally not to be left behind and keeps up with the times.

This article will introduce you to the method of retrieving kintone record information in the WeChat public account.

To put it simply, we will create a new application for managing corporate information in kintone, and then enter keywords in the WeChat official account to retrieve the information in the application.

Since the official public account requires certification, this time we temporarily use the WeChat public account test account.

What it looks like after completion

How to retrieve kintone record information in WeChat

##Preparation

kintone settings


First create based on the above idea kintone application. What I created is a simple version of an enterprise information management application.

After the application is successfully created, enter three pieces of data

How to retrieve kintone record information in WeChat

WeChat public account settings

1. VisitWeChat public platformand click "Enter the WeChat public account test account application system" and apply for the WeChat public account test account

How to retrieve kintone record information in WeChat

2. Enter the WeChat public test account

for testing In the account management page, we can see the appID and appsecret. Write down these two pieces of information, it will be useful later.

How to retrieve kintone record information in WeChat

3. Fill in the interface configuration information

This information requires its own server resources. There are many cloud server resources online, and everyone can choose freely.

If you have a server with a public IP, you can also use it. Below we mainly use the PHP environment (the specific server configuration method is omitted)

Next, write the server verification code to make it Can correctly respond to the Token verification sent by WeChat. For details, please refer toAccess Guide.

How to retrieve kintone record information in WeChat

##Code

class WeChat { private $_appid; private $_appsecret; private $_token; public function __construct($appid, $appsecret, $token) { $this->_appid = $appid; $this->_appsecret = $appsecret; $this->_token = $token; } public function valid() { $echoStr = $_GET["echostr"]; //valid signature , option if($this->checkSignature()) { echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = $this->_token; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ) { return true; } else { return false; } } }
Copy after login


How to retrieve kintone record information in WeChat


How to retrieve kintone record information in WeChat

php documentationandkintone API: Get records in batches (specify conditions in the query).

All codes can be viewed here

WeChat public platform technical documentation

Field type Field name Field code Remarks Creator Creator Creator Creation time Creation Time Creation time ##Single-line text box Set as required Single-line text box Single line text box Single line text box Single line text box
valid(); //Token验证 ?>
Copy after login
Click "Modify" of the interface configuration information, After filling in the URL and Token, click the "Submit" button.If you see the following information, the configuration is successful.Associated with kintoneThe following is the main schematic diagram. WeChat forwards the message to the server, and after the server interacts with kintone, the result is returned to the official account.To interact with kintone, we mainly use the curl tool and kintone's API to retrieve records. For details, please refer to
// 请求头部 $header = array( "Host: " . $this->_subDomain . ".cybozu.com:443", "X-Cybozu-API-Token: " . $this->_apiToken ); $queryStr = 'company like "'. $keyword. '"'; $params = "?app=$this->_appId&query=".urlencode($queryStr) . "&fields[0]=". urlencode("company") . "&fields[1]=". urlencode("representative") . "&fields[2]=". urlencode("area") . "&fields[3]=". urlencode("address") . "&fields[4]=". urlencode("tel"); $url = "https://" . $this->_subDomain . ".cybozu.com/k/v1/records.json". $params; $response = $this->_request($url, true, "get", null, $header); //curl提交 $result = json_decode($response, true); if (count($result["records"]) > 0) { foreach($result["records"] as $value) { if ($contentStr != '') { $contentStr .= "\n\n"; } $contentStr .= "公司名:". $value["company"]["value"]."\n" . "公司代表:". $value["representative"]["value"]."\n" . "地域:". $value["area"]["value"]."\n" . "所在地:". $value["address"]["value"]."\n" . "电话:". $value["tel"]["value"]; } } else { $contentStr = "未找到该企业信息"; }
Copy after login
Detailed codeReference


Company name company

The value is unique

Company representative representative
Region area
Location address
Company phone number tel

The above is the detailed content of How to retrieve kintone record information in WeChat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Articles by Author
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!