Commit 56885084 authored by hujun's avatar hujun

方法名修改

parent 454177c6
......@@ -26,20 +26,58 @@ class GeTuiUtils
{
include_once(EXTEND_PATH . 'GETUI_PHP_SDK/IGt.Push.php');
}
/**
* 对某个人推送消息
*
* @param $id
* @param $device_id
* @param $title
* @param $content
* @param string $type
* @param $user_id
* @return array
* @throws \Exception
*/
public function pushToPerson($id, $device_id, $title, $content, $type = 'other', $user_id = null)
{
$home_url = $this->httpHost();
$data['agent_id'] = $id;
$data['black_title'] = $title;
$data['content'] = $content;
$data['device_id'] = $device_id;
$data['touchuan'] = json_encode([
'title' => $title,
'content' => $content,
'type' => $type,
'url' => '',
'name' => $title,
'id' => $user_id,
'imageUrl' => $home_url . 'notice_android_logo.png' ]);
try {
$result = $this->pushMessageToIgt($data);
} catch (\Exception $e) {
$result['result'] = 'error';
$result['status'] = $e->getMessage();
}
return $result;
}
/**
* @param $data
* @return array
* @throws \Exception
*/
function push_message_for_one($data)
public function pushMessageToIgt($data)
{
$cid = $data['device_id'];
$igt = new \IGeTui(IGT_HOST, IGT_APP_KEY, IGT_MASTER_SECRET);
//模板
$template = $this->online_all_template($data['touchuan'], $data['black_title'], $data['content']);
$template = $this->onlineAllTemplate($data['touchuan'], $data['black_title'], $data['content']);
//个推信息体
$message = new \IGtSingleMessage();
......@@ -71,7 +109,7 @@ class GeTuiUtils
* @return \IGtTransmissionTemplate
* @throws \Exception
*/
function online_all_template($payload, $black_title, $content)
function onlineAllTemplate($payload, $black_title, $content)
{
$template = new \IGtTransmissionTemplate();
......@@ -81,7 +119,7 @@ class GeTuiUtils
$template->set_transmissionContent($payload); //透传内容
//APN高级推送
$apn = new \IGtAPNPayload();
$apn = new \IGtAPNPayload();
$alert_msg = new \DictionaryAlertMsg();
$alert_msg->body = $content;//对应的是在线透传的content
$alert_msg->actionLocKey = "打开同联商业";//滑动打开app
......@@ -96,43 +134,13 @@ class GeTuiUtils
$template->set_apnInfo($apn);
return $template;
}
/**
* 对某个人推送消息
*
* @param $id
* @param $device_id
* @param $title
* @param $content
* @param string $type
* @param $user_id
* @return array
* @throws \Exception
*/
function public_push_message_for_one($id, $device_id, $title, $content, $type = 'other', $user_id)
{
$home_url = $this->http_host();
$data['agent_id'] = $id;
$data['black_title'] = $title;
$data['content'] = $content;
$data['device_id'] = $device_id;
$data['touchuan'] = json_encode([
'title' => $title,
'content' => $content,
'type' => $type,
'url' => '',
'name' => $title,
'id' => $user_id,
'imageUrl' => $home_url . 'notice_android_logo.png' ]);
return $this->push_message_for_one($data);
}
/**
* 当前域名
*
* @return string
*/
public function http_host()
public function httpHost()
{
$http_type =
((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
......@@ -148,17 +156,17 @@ class GeTuiUtils
* @param null $data
* @return mixed|string
*/
function http_request($url, $data = null)
function httpRequest($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if (curl_errno($curl)) {
return 'Error_no' . curl_error($curl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment