card message

This commit is contained in:
候学杰 2019-01-02 15:17:32 +08:00
parent 1107190667
commit cf9591a0b5
2 changed files with 61 additions and 1 deletions

View File

@ -53,3 +53,63 @@ function user_text_alert($username, $text)
return $resp;
}
/**
* 对微信群发送文本卡片
* @param $chat
* @param $title
* @param $desc
* @param $button
* @param $url
* @return mixed|null
*/
function chat_card_alert($chat, $title, $desc, $button, $url)
{
$client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
try {
$resp = $client->call('work/card', [
'chat_id' => $chat,
'title' => $title,
'desc' => $desc,
'button' => $button,
'url' => $url,
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
return null;
}
return $resp;
}
/**
* 对单个或多个用户发送文本卡片多个用户id使用 | 隔开
* @param $username
* @param $title
* @param $desc
* @param $button
* @param $url
* @return mixed|null
*/
function user_card_alert($username, $title, $desc, $button, $url)
{
$client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
try {
$resp = $client->call('work/card', [
'username' => $username,
'title' => $title,
'desc' => $desc,
'button' => $button,
'url' => $url,
]);
} catch (Exception $ex) {
var_dump($ex->getMessage());
return null;
}
return $resp;
}

View File

@ -5,7 +5,7 @@ ini_set('display_errors', 'stderr');
require_once dirname(__DIR__).'/vendor/autoload.php';
$ret = user_text_alert('houxuejie','dfdfdf');
$ret = chat_card_alert('szjesh','dfdfdf');
var_dump($ret);
if( $ret['err_code'] == '0' ){
echo "发送成功\n";