當前位置:首頁 » 編程語言 » php極光推送

php極光推送

發布時間: 2022-10-04 02:10:39

php 怎麼做 內部的消息推送呢

?可以用第三方軟體極光推送來實現。對於定製化需求較強的,或者想擁有自己推送平台的開發者,極光提供全功能的私有雲方案。
極光推送快速開始步驟: 1、到極光推送官方網站注冊開發者帳號;
2、登錄進入管理控制台,創建應用程序,得到 Appkey(SDK 與伺服器端通過 Appkey 互相識別);
3、在推送設置中給 Android 設置包名、給 iOS 上傳證書、啟用 WinPhone,根據你的需求進行選擇;
4、下載 SDK 集成到 App 里。
客戶端初始化 JPush 成功後,JPush 服務端會分配一個 Registration ID,作為此設備的標識(同一個手機不同 App 的 Registration ID 是不同的)。開發者可以通過指定具體的 Registration ID 來進行對單一設備的推送。

㈡ 在php怎樣調用極光推送推送信息

<?php
/**
* 極光推送
*/
class jpush {
private $_masterSecret = '';
private $_appkeys = '';
/**
* 構造函數
* @param string $username
* @param string $password
* @param string $appkeys
*/
function __construct($masterSecret = '',$appkeys = '') {
$this->_masterSecret = $masterSecret;
$this->_appkeys = $appkeys;
}
/**
* 模擬post進行url請求
* @param string $url
希望對你有用,我在後盾人線下面授培訓學習剛下課,有不會的可以問我(;´༎ຶ㉨༎ຶ`)

㈢ php極光推送驗證失敗怎麼解決

下面貼上代碼,使用的是極光推送PHP SDK的master分支:
try {
$this->client->push()
->setPlatform(['android','ios'])
->options(['apns_proction'=>true])//蘋果生產環境
->addRegistrationId($user_list)
->iosNotification($alert_info,[
'sound'=>'sound.caf',
'badge'=>'+1',
'extras'=>$data
])
->androidNotification($alert_info,[
'title'=>'MU直播',
'extras'=>$data
])
->send();
}catch (APIConnectionException $e)
{
Log::info($e);
}catch(APIRequestException $e)
{
Log::info($e);
}

㈣ 極光推送 php 怎麼向特定的手機

客戶端會有一個deviceid的,你記錄那個,到時候發送的時候用$client->device()->updateDevice這個方法,第一個參數是deviceid,第二個參數是你用戶表的唯一標識符,然後就可以push了

㈤ PHP極光推送如何自定義消息提醒聲音。

->iosNotification($Content,Array('badge'=>'+1','sound'=>'sub.caf'))

這是ios的,安卓我之前測試貌似不行

㈥ laravel 極光推送 php sdk怎麼使用

php 極光推送

error_reporting(E_ALL^E_NOTICE);
class ApipostAction{
/**
* 模擬post進行url請求
* @param string $url
* @param string $param
*/
private $_appkeys = 'f722b1337ded85********';
private $_masterSecret = 'bd267a37c30**********';

function request_post($url="",$param="") {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定網頁
curl_setopt($ch, CURLOPT_HEADER, 0);//設置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求結果為字元串且輸出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//運行curl
curl_close($ch);
return $data;
}
/**
* 發送
* @param int $sendno 發送編號。由開發者自己維護,標識一次發送請求
* @param int $receiver_type 接收者類型。1、指定的 IMEI。此時必須指定 appKeys。2、指定的 tag。3、指定的 alias。4、 對指定 appkey 的所有用戶推送消息。* @param string $receiver_value 發送范圍值,與 receiver_type相對應。 1、IMEI只支持一個 2、tag 支持多個,使用","間隔。 3、alias 支持多個,使用","間隔。 4、不需要填
* @param int $msg_type 發送消息的類型:1、通知 2、自定義消息
* @param string $msg_content 發送消息的內容。 與 msg_type 相對應的值
* @param string $platform 目標用戶終端手機的平台類型,如: android, ios 多個請使用逗號分隔
*/
function send($sendno = 15,$receiver_type = 1, $receiver_value ="", $msg_type = 1, $msg_content ="", $platform = 'android')
{
$url = 'http://api.jpush.cn:8800/sendmsg/v2/sendmsg';
$param = '';
$param .= '&sendno='.$sendno;
$appkeys = $this->_appkeys;
$param .= '&app_key='.$appkeys;
$param .= '&receiver_type='.$receiver_type;
$param .= '&receiver_value='.$receiver_value;
$masterSecret = $this->_masterSecret;
$verification_code = md5($sendno.$receiver_type.$receiver_value.$masterSecret);
$param .= '&verification_code='.$verification_code;
$param .= '&msg_type='.$msg_type;
$param .= '&msg_content='.$msg_content;
$param .= '&platform='.$platform;

$res = $this->request_post($url, $param);

$res_arr = json_decode($res, true);

print_r($res_arr);
}
}

$platform = 'android,ios'; // 接受此信息的系統
$msg_content = json_encode(array('n_builder_id'=>1,'n_title'=>'標題', 'n_content'=>'內容','n_extras'=>array('fromer'=>'發送者','fromer_name'=>'發送者名字','fromer_icon'=>'發送者頭像','image'=>'發送圖片鏈接','sound'=>'發送音樂鏈接')));
$jpush=new ApipostAction();
$jpush->send(16,4,"",1,$msg_content,$platform);

㈦ thinkphp怎麼引入極光推送庫

下載官方demo解壓出來放到vender文件夾下(vender/jpush->目錄下會有個autoload.php文件).

在需要用的地方使用vender助手函數

vendor('jpush.autoload');//引入
$app_key='';//key
$master_secret='';//秘鑰
$client=newJPushClient($app_key,$master_secret);
$pusher=$client->push()////這里需要些你需要發送的配置參數內容等///->send();
$pusher->send();//發送

㈧ php 怎麼讓極光推送消息不重復

<?php

/**

* 極光推送

*/

class jpush {

private $_masterSecret = '';

private $_appkeys = '';

/**

* 構造函數

* @param string $username

* @param string $password

* @param string $appkeys

*/

function __construct($masterSecret = '',$appkeys = '') {

$this->_masterSecret = $masterSecret;

$this->_appkeys = $appkeys;

}

/**

* 模擬post進行url請求

* @param string $url

* @param string $param

*/

function request_post($url="",$param="",$header="") {

if (empty($url) || empty($param)) {

return false;

}

$postUrl = $url;

$curlPost = $param;

$ch = curl_init();//初始化curl

curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定網頁

curl_setopt($ch, CURLOPT_HEADER, 0);//設置header

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求結果為字元串且輸出到屏幕上

curl_setopt($ch, CURLOPT_POST, 1);//post提交方式

curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);

curl_setopt($ch, CURLOPT_HTTPHEADER,$header);

// 增加 HTTP Header(頭)里的欄位

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

// 終止從服務端進行驗證

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

$data = curl_exec($ch);//運行curl

curl_close($ch);

return $data;

}

/* $receiver 接收者的信息

all 字元串 該產品下面的所有用戶. 對app_key下的所有用戶推送消息

tag(20個)Array標簽組(並集): tag=>array('昆明','北京','曲靖','上海');

tag_and(20個)Array標簽組(交集): tag_and=>array('廣州','女');

alias(1000)Array別名(並集): alias=>array('93d78b73611d886a74*****88497f501','606d05090896228f66ae10d1*****310');

registration_id(1000)注冊ID設備標識(並集): registration_id=>array('20effc071de0b45c1a**********');

*/

//$content 推送的內容。

//$extras 附加欄位

//$m_time 保存離線時間的秒數默認為一天(可不傳)單位為秒

//$message_type消息類型,0消息,1通知

public function pushMessage($title='',$message='',$receiver='all',$message_type=0,$extras=array(),$m_time='86400',$platform='all'){

$url = 'https://api.jpush.cn/v3/push';

$base64=base64_encode("$this->_appkeys:$this->_masterSecret");

$header=array("Authorization:Basic $base64","Content-Type:application/json");

$data = array();

$data['platform'] = $platform; //目標用戶終端手機的平台類型android,ios,winphone

$data['audience'] = $receiver; //目標用戶

if($message_type == 1){

$data['notification'] = array(

//統一的模式--標准模式

"alert"=>$message,

//安卓自定義

"android"=>array(

"alert"=>$message,

"title"=>$title,

"builder_id"=>1,

"extras"=> $extras

),

//ios的自定義

"ios"=>array(

// "alert"=>$content,

"badge"=>"1",

"sound"=>"default",

// "extras"=>array("type"=>$m_type, "txt"=>$m_txt)

),

);

}else{

//蘋果自定義---為了彈出值方便調測

$data['message'] = array(

"title"=> $title,

"msg_content" =>$message,

"extras"=>$extras

);

}

//附加選項

$data['options'] = array(

"sendno"=>time(),

"time_to_live"=>$m_time, //保存離線時間的秒數默認為一天

"apns_proction"=>1, //指定 APNS 通知發送環境:0開發環境,1生產環境。

);

$param = json_encode($data);

$res = $this->request_post($url, $param,$header);

if ($res === false) {

return false;

}

$res_arr = json_decode($res, true);

return $res_arr;

}

}

/**

* 使用方法

*/

$appkeys='';

$masterSecret='';

$jpush = new jpush($masterSecret,$appkeys);

$title = '標題';

$message = '消息內容';

$message_type = 0;

$receiver = 'all';//接收者

$extras = array();

$jpush->pushMessage($title,$message,$receiver,$message_type,$extras);

㈨ 請問下,極光推送php服務端除了將文字推送到app上外,怎麼將url推送到app上

推送的內容不是自定義的么?你在數據中加一個url選項不就可以了!另外跳轉鏈接這種工作還是得你代碼實現哦! 激光人家只負責推送,不負責處理邏輯哦!

熱點內容
現在玩游戲的電腦需要什麼配置 發布:2024-04-20 17:09:57 瀏覽:195
游樂園的密碼一般為多少 發布:2024-04-20 17:09:51 瀏覽:41
興元安卓機怎麼進系統 發布:2024-04-20 17:07:16 瀏覽:806
我的世界伺服器如何放村民 發布:2024-04-20 17:05:35 瀏覽:359
手機反編譯dex 發布:2024-04-20 17:01:01 瀏覽:704
安卓怎麼設置微信拍一拍 發布:2024-04-20 16:44:48 瀏覽:569
三星3熱點密碼怎麼設置 發布:2024-04-20 16:30:52 瀏覽:579
用keil編譯顯示警告warn 發布:2024-04-20 16:27:09 瀏覽:894
訪問在哪兒 發布:2024-04-20 16:20:42 瀏覽:201
安卓手機有什麼可以把聲音改成電音的軟體 發布:2024-04-20 16:19:40 瀏覽:564