You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.8 KiB
128 lines
3.8 KiB
2 months ago
|
<?php
|
||
|
namespace LaneWeChat\Core;
|
||
|
|
||
|
class ResponseInitiative{
|
||
|
|
||
|
protected static $queryUrl = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=';
|
||
|
|
||
|
protected static $action = 'POST';
|
||
|
public static function text($tousername, $content){
|
||
|
|
||
|
$accessToken = AccessToken::getAccessToken();
|
||
|
self::$queryUrl = self::$queryUrl.$accessToken;
|
||
|
|
||
|
$template = array(
|
||
|
'touser'=>$tousername,
|
||
|
'msgtype'=>'text',
|
||
|
'text'=>array(
|
||
|
'content'=>$content,
|
||
|
),
|
||
|
);
|
||
|
$template = json_encode($template);
|
||
|
|
||
|
return Curl::callWebServer(self::$queryUrl, $template, self::$action);
|
||
|
}
|
||
|
|
||
|
public static function image($tousername, $mediaId){
|
||
|
//获取ACCESS_TOKEN
|
||
|
$accessToken = AccessToken::getAccessToken();
|
||
|
self::$queryUrl = self::$queryUrl.$accessToken;
|
||
|
|
||
|
//开始
|
||
|
$template = array(
|
||
|
'touser'=>$tousername,
|
||
|
'msgtype'=>'image',
|
||
|
'image'=>array(
|
||
|
'media_id'=>$mediaId,
|
||
|
),
|
||
|
);
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer(self::$queryUrl, $template, self::$action);
|
||
|
}
|
||
|
|
||
|
public static function voice($tousername, $mediaId){
|
||
|
//获取ACCESS_TOKEN
|
||
|
$accessToken = AccessToken::getAccessToken();
|
||
|
self::$queryUrl = self::$queryUrl.$accessToken;
|
||
|
|
||
|
//开始
|
||
|
$template = array(
|
||
|
'touser'=>$tousername,
|
||
|
'msgtype'=>'voice',
|
||
|
'voice'=>array(
|
||
|
'media_id'=>$mediaId,
|
||
|
),
|
||
|
);
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer(self::$queryUrl, $template, self::$action);
|
||
|
}
|
||
|
|
||
|
public static function video($tousername, $mediaId, $title, $description){
|
||
|
//获取ACCESS_TOKEN
|
||
|
$accessToken = AccessToken::getAccessToken();
|
||
|
self::$queryUrl = self::$queryUrl.$accessToken;
|
||
|
|
||
|
//开始
|
||
|
$template = array(
|
||
|
'touser'=>$tousername,
|
||
|
'msgtype'=>'video',
|
||
|
'video'=>array(
|
||
|
'media_id'=>$mediaId,
|
||
|
'title'=>$title,
|
||
|
'description'=>$description,
|
||
|
),
|
||
|
);
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer(self::$queryUrl, $template, self::$action);
|
||
|
}
|
||
|
|
||
|
|
||
|
public static function music($tousername, $title, $description, $musicUrl, $hqMusicUrl, $thumbMediaId){
|
||
|
//获取ACCESS_TOKEN
|
||
|
$accessToken = AccessToken::getAccessToken();
|
||
|
self::$queryUrl = self::$queryUrl.$accessToken;
|
||
|
|
||
|
//开始
|
||
|
$template = array(
|
||
|
'touser'=>$tousername,
|
||
|
'msgtype'=>'music',
|
||
|
'music'=>array(
|
||
|
'title'=>$title,
|
||
|
'description'=>$description,
|
||
|
'musicurl'=>$musicUrl,
|
||
|
'hqmusicurl'=>$hqMusicUrl,
|
||
|
'thumb_media_id'=>$thumbMediaId,
|
||
|
),
|
||
|
);
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer(self::$queryUrl, $template, self::$action);
|
||
|
}
|
||
|
|
||
|
public static function newsItem($title, $description, $picUrl, $url){
|
||
|
return $template = array(
|
||
|
'title'=>$title,
|
||
|
'description'=>$description,
|
||
|
'url'=>$picUrl,
|
||
|
'picurl'=>$url,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public static function news($tousername, $item){
|
||
|
|
||
|
$accessToken = AccessToken::getAccessToken();
|
||
|
self::$queryUrl = self::$queryUrl.$accessToken;
|
||
|
|
||
|
|
||
|
$template = array(
|
||
|
'touser'=>$tousername,
|
||
|
'msgtype'=>'news',
|
||
|
'news'=>array(
|
||
|
'articles'=>$item
|
||
|
),
|
||
|
);
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer(self::$queryUrl, $template, self::$action);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|