当前位置: 首页>>代码示例>>PHP>>正文


PHP Wechat::sendTemplateMessage方法代码示例

本文整理汇总了PHP中Wechat::sendTemplateMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::sendTemplateMessage方法的具体用法?PHP Wechat::sendTemplateMessage怎么用?PHP Wechat::sendTemplateMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wechat的用法示例。


在下文中一共展示了Wechat::sendTemplateMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send_wechat_msg_pe

function send_wechat_msg_pe($staff_openid, $template_id, $url_ticket_id, $first_data, $remark_data, $keyword1_data, $keyword2_data, $keyword3_data = null)
{
    $notice_data = ["touser" => $staff_openid, "template_id" => $template_id, "url" => "https://wechat.gds-services.com/static/html/query_req_detail.html?tid=" . $url_ticket_id, "topcolor" => "#000", "data" => ["first" => ["value" => $first_data, "color" => "#000"], "remark" => ["value" => $remark_data, "color" => "#000"], "keyword1" => ["value" => $keyword1_data, "color" => "#000"], "keyword2" => ["value" => $keyword2_data, "color" => "#000"]]];
    if (!empty($keyword3_data) && $keyword3_data != null) {
        $notice_data->data->keyword3 = ["value" => $keyword3_data, "color" => "#000"];
    }
    $options = ['token' => 'nizhidaoma', 'encodingaeskey' => 'IXR7m0K8Q7KOIC4z9s1CRHNQBqrJfFGTUT86CECPaXM', 'appid' => 'wx6bc0c53a3a1c150d', 'appsecret' => '3888ccc01ec4e5d6e0e673308e92e627', 'debug' => true, 'logcallback' => '_log'];
    include dirname(__FILE__) . "/../qy-sdk/wechat.class.php";
    $weObj = new Wechat($options);
    return $weObj->sendTemplateMessage($notice_data);
}
开发者ID:adexbn,项目名称:gds_wechat,代码行数:11,代码来源:send_wechat_test.php

示例2: send_wechat_msg_pe

function send_wechat_msg_pe($notice_id, $staff_openid, $staff_type, $template_id, $url_ticket_id, $first_data, $remark_data, $keyword1_data, $keyword2_data, $keyword3_data = null)
{
    $staff_openid = $staff_openid['openid'];
    if (TEST_SEND) {
        $staff_openid = DEBUG_WECHAT_PE;
    }
    $notice_data = ["touser" => $staff_openid, "template_id" => $template_id, "url" => "https://wechat.gds-services.com/static/html/query_req_detail.html?tid=" . $url_ticket_id, "topcolor" => "#000", "data" => ["first" => ["value" => $first_data, "color" => "#000"], "remark" => ["value" => $remark_data, "color" => "#000"], "keyword1" => ["value" => $keyword1_data, "color" => "#000"], "keyword2" => ["value" => $keyword2_data, "color" => "#000"]]];
    if (!empty($keyword3_data) && $keyword3_data != null) {
        $notice_data->data->keyword3 = ["value" => $keyword3_data, "color" => "#000"];
    }
    //Log send data
    $notice_id = save_notice_log($notice_id, 'wechat_' . $staff_type, $staff_openid, json_encode($notice_data, JSON_UNESCAPED_UNICODE));
    $notice_result = false;
    //Do Send
    $options = ['token' => 'nizhidaoma', 'encodingaeskey' => 'IXR7m0K8Q7KOIC4z9s1CRHNQBqrJfFGTUT86CECPaXM', 'appid' => 'wx6bc0c53a3a1c150d', 'appsecret' => '3888ccc01ec4e5d6e0e673308e92e627', 'debug' => true, 'logcallback' => '_log'];
    if (REAL_SEND) {
        $weObj_PE = new Wechat($options);
        $wechat_result = $weObj_PE->sendTemplateMessage($notice_data);
        _log('Send Wechat PE result... ' . var_export($wechat_result, true));
        if ($wechat_result != FALSE) {
            $notice_result = isset($wechat_result['msgid']) ? 1 : -1;
        } else {
            _log('Send Wechat PE failed... (' . $weObj_PE->errCode . ')' . $weObj_PE->errMsg);
        }
    }
    //Log send result
    update_notice_log($notice_id, $notice_result);
    return $notice_result;
}
开发者ID:adexbn,项目名称:gds_wechat,代码行数:29,代码来源:notification_send.php


注:本文中的Wechat::sendTemplateMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。