Douyin seo matrix system source code development -- private message function of intended customers

Table of contents

1. Introduction to matrix number system?

2. The current common forms of matrix promotion are

3. Core function development

4. Development of automatic private message function of intention clues

Access process

Preparation before access

App settled

Access Douyin Authorization

Message Unified Structure

Development code display

1. Introduction to matrix number system?

The matrix number system is mainly a promotion method to expand the publicity effect of enterprises and enterprise products through the release of relevant promotional videos on multiple platforms and multiple accounts.

2. The current common forms of matrix promotion are

1. Family matrix 

2. Team matrix

3. MCN matrix 

4. Personal matrix.

3. Core function development

1. Unified management of multiple accounts and multiple platforms

2. AI smart editing

3. Timing delivery of video content

4. Data Tracking

5. Intelligent online customer service

6. Division of corporate functions

7. Automatic Lead Assignment

4. Development of automatic private message function of intention clues

Access process

Preparation before access

App settled

  • Developers need to enter the Douyin open platform , create a website application with message management as one of the core function scenarios, and obtain the application clientkey

Access Douyin Authorization

  • Currently, message management related capabilities only support web code scanning authorization

Message Unified Structure

{
    "event": "receive_msg",
    "from_user_id": "",
    "to_user_id": "",
    "client_": "",
    "content": {}
}

Development code display

$daid = $this->request->getIntParam('daid', 0);
        //应用类型输出
        $where = [
            ['name' => 'cl_ds_id', 'oper' => '=', 'value' => $this->sid],
        ];
        if (!empty($daid)) {
            $where[] = ['name' => 'dl_qyh_uid', 'oper' => '=', 'value' => $daid];
        }
        $this->output['enter_id'] = $daid;
        $sort = ['cl_create_time' => 'DESC'];

        $chat_list_model = new App_Model_Douyin_MysqlChatListStorage();
        $chat_result = $chat_list_model->getList($where, $this->index, $this->count, $sort);

        $intent_model = new App_Model_Douyin_MysqlIntentUserStorage();
        #$account_model  = new App_Model_Douyin_MysqlDyAccountStorage();

        $chat_list = [];
        foreach ($chat_result as $item) {
            #$account    = $account_model->getRowByIdSid($item['cl_qyh_uid'], $this->sid);
            $intention = $intent_model->getUserByOpenId($this->sid, $item['cl_from_openid']);

            $each = [
                'user_nickname' => empty($intention) ? '匿名' : $intention['iu_nickname'],
                'user_avatar' => empty($intention) ? parent::TEMPLATE_PLACEHOLDER_IMAGE : $intention['iu_avatar'],
                'user_newmsg' => $item['cl_new_text'],
                'user_newtime' => date('Y-m-d H:i:s', $item['cl_new_time']),
                'user_openid' => $item['cl_from_openid'],
                'qyh_uid' => $item['cl_qyh_uid'],
                'undo_count' => $item['cl_undo_count'],
            ];
            array_push($chat_list, $each);
        }

        $this->displayJson($chat_list);

$from_openid = $this->request->getStrParam('from_openid');
        $qyh_uid = $this->request->getIntParam('qyh_uid');

        $letter_model = new App_Model_Douyin_MysqlLetterStorage();
        $detail_result = $letter_model->getChatListOrder($from_openid, $qyh_uid, $this->sid, $this->index, $this->count);

        $chat_detail = [];
        foreach ($detail_result as $item) {
            $each = [
                'msg_type' => $item['dl_msg_type'],
                'msg_content' => $item['dl_msg_content'],
                'msg_time' => date('Y-m-d H:i:s', $item['dl_create_time']),
                'send_receive' => intval($item['dl_send_receive']),    //1收到的消息,2发送的消息
            ];

            array_push($chat_detail, $each);
        }
        $account_model = new App_Model_Douyin_MysqlDyAccountStorage();
        $qyh_account = $account_model->getRowByIdSid($qyh_uid, $this->sid);
        $intent_model = new App_Model_Douyin_MysqlIntentUserStorage();
        $from_account = $intent_model->getUserByOpenId($this->sid, $from_openid, $qyh_uid);

        $return_data = [
            'from_user' => [
                'nickname' => empty($from_account) ? '匿名' : $from_account['iu_nickname'],
                'avatar' => empty($from_account) ? parent::TEMPLATE_PLACEHOLDER_IMAGE : $from_account['iu_avatar'],
                'openid' => $from_openid,
            ],
            'to_user' => [
                'nickname' => $qyh_account['da_nickname'],
                'avatar' => $qyh_account['da_avatar'],
                'qyh_uid' => $qyh_uid,
            ],
            'chat_detail' => $chat_detail
        ];
        $chat_list_model = new App_Model_Douyin_MysqlChatListStorage();
        $cl_where = [
            ['name' => 'cl_ds_id', 'oper' => '=', 'value' => $this->sid],
            ['name' => 'cl_qyh_uid', 'oper' => '=', 'value' => $qyh_uid],
            ['name' => 'cl_from_openid', 'oper' => '=', 'value' => $from_openid],
        ];
        $chat_list_model->updateValue(['cl_undo_count' => 0], $cl_where);
        $this->displayJson($return_data);

Guess you like

Origin blog.csdn.net/m0_71850852/article/details/126183326