97久久国产亚洲精品超碰热,成人又色又爽的免费网站,色偷偷女人的天堂a,男女高潮喷水在线观看,国内精品一线二线三线区别在哪里

返回列表 發(fā)帖
查看: 2130|回復(fù): 5

通過掌上論壇的回帖不觸發(fā)鉤子函數(shù)

11

主題

29

回帖

45

積分

初學(xué)乍練

貢獻(xiàn)
0 點(diǎn)
金幣
2 個(gè)
樓主
發(fā)表于 2022-2-5 10:32:31 | 只看樓主 |倒序?yàn)g覽 |閱讀模式
我寫了一個(gè)很簡單的鉤子函數(shù)

  1. <?php

  2. if (!defined('IN_DISCUZ')) {

  3.     exit('Access Denied');
  4. }

  5. function sendPostRequest($url,$jsonData){

  6.     $curl = curl_init($url);
  7.     curl_setopt($curl, CURLOPT_HEADER, false);
  8.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  9.     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
  10.     curl_setopt($curl, CURLOPT_POST, true);
  11.     curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($jsonData));
  12.     // set a very low timeout to avoid blocking
  13.     curl_exec($curl);
  14.     curl_close($curl);
  15. }

  16. class plugin_dhpush {}




  17. class plugin_dhpush_forum extends plugin_dhpush
  18. {

  19.     function __construct()
  20.     { //全局函數(shù)定義
  21.         global $_G;
  22.         $config = $_G['cache']['plugin']['dhpush'];
  23.         $this->groupid = $_G['groupid'];
  24.         $this->allowPushGroupIds = unserialize($config["allowPushGroups"]);
  25.         $this->pushToken = $config["pushToken"];
  26.     }

  27.     function post_reply_output($params)
  28.     {
  29.         global $_G;
  30.         $DEBUG = true;
  31.         $SEND_URL_PREFIX = "https://dhpushservice.kidozh.com/";
  32.         $SEND_URL_PATH = "v1/push/reply/";
  33.         if ($DEBUG) {
  34.             $SEND_URL_PREFIX = "http://localhost:8888/";

  35.         }

  36.         $SEND_URL = $SEND_URL_PREFIX.$SEND_URL_PATH;

  37.         error_log(print_r($params, TRUE));
  38.         // check with post reply succeed
  39.         if ($params["message"] != "post_reply_succeed") {
  40.             return;
  41.         }
  42.         $fid = $params['values']['fid'];
  43.         $tid = $params['values']['tid'];
  44.         $pid = $params['values']['pid'];


  45.         $mForumPost = C::t("forum_post");
  46.         $post = $mForumPost->fetch($tid, $pid);
  47.         $senderUid = $post["authorid"];
  48.         $senderName = $post["author"];
  49.         $replyMessage = $post["message"];

  50.         $mForumThread = C::t('forum_thread');

  51.         $thread = $mForumThread->fetch($tid);
  52.         //主題作者ID
  53.         $authorId = $thread['authorid'];
  54.         $userResult = DB::fetch_first("SELECT groupid FROM " . DB::table("common_member") . " WHERE uid=" . $authorId);
  55.         $receiverGroupId = $userResult["groupid"];
  56.         //判斷作者是否開啟回貼通知
  57.         //$mForumPostNotice = C::t('#post_notice#forum_post_notice');
  58.         //$isNotice = $mForumPostNotice->getNoticeState($authorId);
  59.         // allow notify
  60.         if (true) {
  61.             $mCommonMember = C::t('common_member');
  62.             $author = $mCommonMember->fetch($authorId);
  63. //            $email = $author['email'];
  64.             $title = $senderName . '回復(fù)了帖子' . $thread["subject"];
  65.             $siteURL = $_G["siteurl"];
  66.             // check whether group id is not null and in the allowed group
  67.             if ($receiverGroupId && in_array($receiverGroupId, $this->allowPushGroupIds)) {
  68.                 // look in the table whether the user in the push database
  69.                 $pushInfo = DB::fetch_first("SELECT uid, token, allowPush FROM " . DB::table("dhpush_token") . " WHERE uid=" . $authorId);
  70.                 // start to push the information to device via firebase
  71.                 $token = $pushInfo["token"];
  72.                 $deviceToken = $token;
  73.                 $data = [
  74.                     // belong to a reply
  75.                     "site_url" => $siteURL,
  76.                     "type" => "thread_reply",
  77.                     "sender_name" => $senderName,
  78.                     "sender_id" => $senderUid,
  79.                     "message" => $replyMessage,
  80.                     "title" => $title,
  81.                     "tid" => $tid,
  82.                     "pid" => $pid,
  83.                     "fid" => $fid,
  84.                     "tokenList"=> $deviceToken

  85.                 ];

  86.                 $SEND_URL_WITH_PARAMTER = $SEND_URL."?token=".$this->pushToken;

  87.                 sendPostRequest($SEND_URL_WITH_PARAMTER,$data);
  88.                 error_log(print_r($data, TRUE));
  89.                 error_log(print_r($SEND_URL, TRUE));

  90.             } else {
  91.                 // the user are not able to get a push
  92.             }
  93.         } else {
  94.             // not to send a information

  95.         }
  96.     }
  97. }

  98. //    function post_message($params)
  99. //    {
  100. //        return;
  101. //        //file_put_contents('php://stderr', print_r($params, TRUE));
  102. //        error_log(print_r($params, TRUE));
  103. //        global $_G;
  104. //        $fid = $params['param'][2]['fid'];
  105. //        $tid = $params['param'][2]['tid'];
  106. //        $pid = $params['param'][2]['pid'];
  107. //
  108. //        $action=$params['param'][0];
  109. //        if($action=='post_newthread_succeed'){//newthread
  110. //            //TODO For newthread
  111. //        }
  112. //        elseif($action=='post_reply_succeed'){//new reply
  113. //            return;
  114. //            $senderName = $_G["username"];
  115. //            $senderUid = $_G["uid"];
  116. //
  117. //            $mForumThread = C::t('forum_thread');
  118. //            //$tid = $params['values']['tid'];
  119. //            $thread = $mForumThread->fetch($tid);
  120. //            //主題作者ID
  121. //            $authorId = $thread['authorid'];
  122. //            $userResult = DB::fetch_first("SELECT groupid FROM " . DB::table("common_member") . " WHERE uid=" . $authorId);
  123. //            $receiverGroupId = $userResult["groupid"];
  124. //            //判斷作者是否開啟回貼通知
  125. //            //$mForumPostNotice = C::t('#post_notice#forum_post_notice');
  126. //            //$isNotice = $mForumPostNotice->getNoticeState($authorId);
  127. //            // allow notify
  128. //            if (true) {
  129. //                $mCommonMember = C::t('common_member');
  130. //                $author = $mCommonMember->fetch($authorId);
  131. //                $email = $author['email'];
  132. //                $subject = '您的貼子有回復(fù)了!';
  133. //                $body = $author['username'] . "\n";
  134. //                $body .= "您的主題:" . $thread['subject'] . "有回復(fù)了!\n";
  135. //                $body .= "復(fù)制鏈接查看:" . $_G['siteurl'] . "forum.php?mod=viewthread&tid=" . $tid . "\n";
  136. //
  137. //                $replyMessage = $body;
  138. //                // check whether group id is not null and in the allowed group
  139. //                if ($receiverGroupId && in_array($receiverGroupId, $this->allowPushGroupIds)) {
  140. //                    // look in the table whether the user in the push database
  141. //                    $pushInfo = DB::fetch_first("SELECT uid, token, allowPush FROM ".DB::table("dhpush_token")." WHERE uid=" . $authorId);
  142. //                    // start to push the information to device via firebase
  143. //                    $token = $pushInfo["token"];
  144. //                    $deviceToken = $token;
  145. //                    $data = [
  146. //                        // belong to a reply
  147. //                        "type" => "thread_reply",
  148. //                        "sender_name" => $author['username'],
  149. //                        "sender_id" => $senderUid,
  150. //                        "message" => $replyMessage,
  151. //
  152. //                    ];
  153. //                    sendPostRequest($SEND_URL,$data);
  154. //                    error_log(print_r($data, TRUE));
  155. //
  156. //                } else {
  157. //                    // the user are not able to get a push
  158. //                }
  159. //            }
  160. //
  161. //        }
  162. //
  163. //        if ($params['message'] != 'post_reply_succeed') {
  164. //        }
  165. //
  166. //    }

復(fù)制代碼
這個(gè)可以在每次回帖的時(shí)候正常的回調(diào),但是我通過掌上論壇API調(diào)用的時(shí)候卻并不觸發(fā)這個(gè)鉤子函數(shù),我想問問是什么原因,需要做哪些事情才能讓通過掌上論壇API發(fā)帖的時(shí)間被正確的通過鉤子函數(shù)回調(diào)?

2

主題

1410

回帖

2061

積分

應(yīng)用開發(fā)者

啦啦啦~

貢獻(xiàn)
58 點(diǎn)
金幣
325 個(gè)
沙發(fā)
發(fā)表于 2022-2-5 11:39:22 | 只看Ta
試試改成 post_message 嵌入點(diǎn)呢?這個(gè)嵌入點(diǎn)應(yīng)該是不依賴前端的,不過 $params["message"] != "post_reply_succeed" 估計(jì)得改。

11

主題

29

回帖

45

積分

初學(xué)乍練

貢獻(xiàn)
0 點(diǎn)
金幣
2 個(gè)
板凳
 樓主| 發(fā)表于 2022-2-5 22:59:22 | 只看Ta
老周部落 發(fā)表于 2022-2-5 11:39
試試改成 post_message 嵌入點(diǎn)呢?這個(gè)嵌入點(diǎn)應(yīng)該是不依賴前端的,不過 $params["message"] != "post_reply ...

似乎這個(gè)也觸發(fā)不了。。。剛剛試了一下。。。

2

主題

1410

回帖

2061

積分

應(yīng)用開發(fā)者

啦啦啦~

貢獻(xiàn)
58 點(diǎn)
金幣
325 個(gè)
地板
發(fā)表于 2022-2-8 15:37:04 | 只看Ta
kidozh 發(fā)表于 2022-2-5 22:59
似乎這個(gè)也觸發(fā)不了。。。剛剛試了一下。。。

$params["message"] != "post_reply_succeed" 去掉也不行么?

11

主題

29

回帖

45

積分

初學(xué)乍練

貢獻(xiàn)
0 點(diǎn)
金幣
2 個(gè)
5#
 樓主| 發(fā)表于 2022-2-10 04:06:41 | 只看Ta
老周部落 發(fā)表于 2022-2-8 15:37
$params["message"] != "post_reply_succeed" 去掉也不行么?

我試了 沒有辦法通過掌上論壇API觸發(fā),網(wǎng)頁端都是可以的

11

主題

29

回帖

45

積分

初學(xué)乍練

貢獻(xiàn)
0 點(diǎn)
金幣
2 個(gè)
6#
 樓主| 發(fā)表于 2022-2-11 23:55:46 | 只看Ta
老周部落 發(fā)表于 2022-2-8 15:37
$params["message"] != "post_reply_succeed" 去掉也不行么?

我回復(fù)被吞了,我試了一下 是不行的 我嵌入了移動(dòng)端也不行。。。
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

  • 關(guān)注公眾號
  • 有償服務(wù)微信
  • 有償服務(wù)QQ

手機(jī)版|小黑屋|Discuz! 官方交流社區(qū) ( 皖I(lǐng)CP備16010102號 |皖公網(wǎng)安備34010302002376號 )|網(wǎng)站地圖|star

GMT+8, 2025-10-20 09:49 , Processed in 0.036311 second(s), 7 queries , Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2025 Discuz! Team.

關(guān)燈 在本版發(fā)帖
有償服務(wù)QQ
有償服務(wù)微信
返回頂部
快速回復(fù) 返回頂部 返回列表