您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)怎么在PHP項目中實現(xiàn)一個RTX發(fā)送消息提醒功能,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
1、首先在服務(wù)器端安裝RTX的服務(wù)端和客戶端,再安裝SDK開發(fā)包
2、然后再RTX服務(wù)器的安裝路徑下有個WebRoot文件夾,文件夾下有個SendNotify.cgi文件,這就是RTX發(fā)送消息的接口文件,打開文件是懂PHP的都能看懂的代碼,不過需要在頭部加入header頭,以及需要處理一些參數(shù)的編碼
header("Content-Type:text/html;charset=GBK"); $msg = iconv("utf-", "GBK", $msg); $title = iconv("utf-", "GBK", $title);
如果你的所有安裝都是在本地的,那么只需要訪問(默認(rèn)端口8012)即可:
http://127.0.0.1:8012/SendNotify.cgi?msg=消息內(nèi)容&receiver=RTX的賬號(多個用逗號格開)&title=通知的標(biāo)題
以下是修改后的SendNotify.cgi代碼:
<?php /** * Created by PhpStorm. * User: Steven * Date: // * Time: : */ header("Content-Type:text/html;charset=GBK"); require_once "IPLimit.php"; $receiver = $_GET["receiver"]; $msg = $_GET["msg"]; $title = $_GET["title"]; $delaytime = $_GET["delaytime"]; $okurl = $_GET["okurl"]; $errurl = $_GET["errurl"]; if ((strlen($receiver) == ) && (strlen($msg) == ) && (strlen($title) == ) && (strlen($delaytime) == ) && (strlen($okurl) == ) && (strlen($errurl) == ) ) { $receiver = $_POST["receiver"]; $msg = $_POST["msg"]; $title = $_POST["title"]; $delaytime = $_POST["delaytime"]; $okurl = $_POST["okurl"]; $errurl = $_POST["errurl"]; } if (strlen($receiver) == ) { $receiver = ""; } if (strlen($msg) == ) { $msg = ""; } if (strlen($title) == ) { $title = ""; } if (strlen($delaytime) == ) { $delaytime = ; } if (strlen($okurl) == ) { $okurl = ""; } if (strlen($errurl) == ) { $errurl = ""; } $msg = iconv("utf-", "GBK", $msg); $title = iconv("utf-", "GBK", $title); $php_errormsg = NULL; $ObjApi = new COM("Rtxserver.rtxobj"); $objProp = new COM("Rtxserver.collection"); $Name = "ExtTools"; $ObjApi->Name = $Name; $objProp->Add("msgInfo", $msg); $objProp->Add("MsgID", ""); $objProp->Add("Type", ""); $objProp->Add("AssType", ""); if (strlen($title) == ) { $objProp->Add("Title", "??"); } else { $objProp->Add("Title", $title); } $objProp->Add("DelayTime", $delaytime); if (strtolower($receiver) == "all") { $objProp->Add("Username", $receiver); $objProp->Add("SendMode", ""); } else { $objProp->Add("Username", $receiver); } $Result = @$ObjApi->Call(x, $objProp); $errstr = $php_errormsg; if (strcmp($nullstr, $errstr) == ) { if (strlen($okurl) > ) { header("Location: " . $okurl); } else { // echo "<script language=\"JavaScript\">\r\n"; // echo "alert(\"success\")"; //echo "</script>\r\n"; return true; } } else { //send err if (strlen($errurl) > ) { header("Location: " . $errurl); } else { echo $errstr . "<br>"; } } ?>
3、需要注意的是代碼中引入了IPLimit.php文件,所以,訪問的時候可能會提示IP受限,這就需要在RTX服務(wù)端安裝文件下找到一個叫SDKProperty.xml的文件,加入你發(fā)送請求的服務(wù)器IP保存即可
<?xml version="."?> <Property> <APIClient> <IPLimit Enabled=""> <IP>...</IP> <IP>這里是IP地址</IP> </IPLimit> </APIClient> <sdkhttp> <IPLimit Enabled=""> </IPLimit> </sdkhttp> </Property>
4、開發(fā)者只需要封裝一個發(fā)送GET或者POST的方法,例如:
$arr = array( 'title' => $title, //消息的標(biāo)題 'receiver' => $receiver_list, //消息的接受者 'msg' => $msg, //消息內(nèi)容 ); $this->httpsPost('http://...:/SendNotify.cgi', $arr);
看完上述內(nèi)容,你們對怎么在PHP項目中實現(xiàn)一個RTX發(fā)送消息提醒功能有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。