当前位置:首页 » 编程语言 » 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选项不就可以了!另外跳转链接这种工作还是得你代码实现哦! 激光人家只负责推送,不负责处理逻辑哦!

热点内容
安卓版twitter怎么注册 发布:2024-05-03 18:28:05 浏览:893
Python逻辑优先级 发布:2024-05-03 18:26:14 浏览:266
linux查看svn密码 发布:2024-05-03 18:12:47 浏览:803
地铁逃生怎么进入游戏安卓 发布:2024-05-03 17:49:35 浏览:992
aws云存储 发布:2024-05-03 17:48:50 浏览:954
安卓微信王者号怎么转成苹果 发布:2024-05-03 17:44:38 浏览:745
原子类源码 发布:2024-05-03 17:44:19 浏览:165
安卓浏览图片如何全屏 发布:2024-05-03 17:24:08 浏览:104
传奇仓库脚本 发布:2024-05-03 17:23:56 浏览:541
2010数据库技术及应用 发布:2024-05-03 17:21:51 浏览:921