include/chajian/hwpushChajian.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php 
/**
*	来自:信呼开发团队
*	作者:磐石(rainrock)
*	网址:http://www.rockoa.com/
*	华为的推送服务
*	参考的开发:https://developer.huawei.com/consumer/cn/service/hms/catalog/huaweipush_v3.html?page=hmssdk_huaweipush_api_reference_messagesend
*/
class hwpushChajian extends Chajian{
	
	//华为推送的设置【自己编译app】以下2个必须设置
	private $appid 	 	= '';
	private $appsecret 	= '';
	
	
	/**
     * 相关域名定义
     */
    private $tokenurl 	= 'https://oauth-login.cloud.huawei.com/oauth2/v3/token';
    private $pushurl	= 'https://push-api.cloud.huawei.com/v1/{appid}/messages:send';
	
	protected function initChajian()
	{
		if(!$this->appid)$this->appid 			= getconfig('hw_appid');
		if(!$this->appsecret)$this->appsecret 	= getconfig('hw_appsecret');
	}
	
	public function sendbool()
	{
		if($this->appsecret=='')return false;
		return true;
	}
	
	public function setinfo($apid,$apse)
	{
		$this->appid 	 = $apid;
		$this->appsecret = $apse;
		return $this;
	}
	
	/**
	*	获取token
	*/
	public function gettoken(){
		if($this->appid=='' || $this->appsecret=='')return '';
		$token 	= c('cache')->get('hwtoken');
		if(isempt($token)){
			$result = c('curl')->postcurl($this->tokenurl, array( 
				"grant_type" => "client_credentials",
				"client_secret" => $this->appsecret,
				"client_id" => $this->appid, 
			));
			if($result){
				$barr 	= json_decode($result, true);
				$token 	= $barr['access_token'];
				c('cache')->set('hwtoken',$token, $barr['expires_in']-1);
			}
		}
		return $token;
    }
后面还有 19 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。