private static int ApiZaloCallForSendZms(string userId, string message)
    {
        log4net.ILog Log     = log4net.LogManager.GetLogger("ApiZaloCallForSendZms");
        int          reValue = -1;

        try
        {
            const string pageId    = "998973463693604902";
            const string secretKey = "yjODClYNJUSJH8Qt20vT";

            long toUid   = long.Parse(userId);
            var  factory = new ZaloServiceFactory(pageId, secretKey);

            ZaloMessageService messageService = factory.getZaloMessageService();
            //ZaloPageResult objResult = messageService.sendTextMessage(toUid, message, message, false);

            //<pageName> Gui ban <header>
            //<Content>

            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("pageName", "VMG Media");
            data.Add("header", "KQXS");
            data.Add("Content", message);

            ZaloPageResult objResult = messageService.sendTemplateTextMessageByPhoneNum(toUid, "602ed6c4ea8103df5a90", data, "Zms Test", true);

            reValue = objResult.getError();

            Log.Debug(" ");
            Log.Debug(" ");
            Log.Debug("--------------- Zalo CALL API RESULT ----------------------");
            Log.Debug("Zalo API RESULT Err : " + objResult.getError());
            Log.Debug("Zalo API RESULT Id : " + objResult.getId());
            Log.Debug(" ");
            Log.Debug(" ");
        }
        catch (ZaloSdkException ex)
        {
            Log.Debug(" ");
            Log.Debug(" ");
            Log.Debug("--------------- Zalo CALL API Error ----------------------");
            Log.Debug("Zalo API Err : " + ex.getErrorCode());
            Log.Debug("Zalo API Mes : " + ex.getMessage());
            Log.Debug(" ");
            Log.Debug(" ");
        }
        catch (Exception ex)
        {
            Log.Debug("Zalo API StackTrace : " + ex.StackTrace);
        }

        return(reValue);
    }
예제 #2
0
    public static int ApiZaloCallForSendZms(string userId, string message)
    {
        log4net.ILog log     = log4net.LogManager.GetLogger("ZaloController");
        int          reValue = -1;

        try
        {
            const string pageId    = "818146067412659188";
            const string secretKey = "FMRu2GEO2DBIDv3cB6UO";

            long toUid   = long.Parse(userId);
            var  factory = new ZaloServiceFactory(pageId, secretKey);

            ZaloMessageService messageService = factory.getZaloMessageService();

            Dictionary <string, string> data = new Dictionary <string, string>();
            data.Add("pageName", "VMG Media");
            data.Add("header", "KQXS");
            data.Add("Content", message);

            ZaloPageResult objResult = messageService.sendTemplateTextMessageByPhoneNum(toUid, "bb215acb668e8fd0d69f", data, "VMG Zms", true);
            //ZaloPageResult objResult = messageService.sendTemplateTextMessageByPhoneNum(toUid, "99a6594c65098c57d518", data, "VMG Zms", true);
            reValue = objResult.getError();

            log.Debug(" ");
            log.Debug(" ");
            log.Debug("--------------- Zalo CALL API RESULT ----------------------");
            log.Debug("Zalo API RESULT Err : " + objResult.getError());
            log.Debug("Zalo API RESULT Id : " + objResult.getId());
            log.Debug(" ");
            log.Debug(" ");
        }
        catch (ZaloSdkException ex)
        {
            log.Debug(" ");
            log.Debug(" ");
            log.Debug("--------------- Zalo CALL API Error ----------------------");
            log.Debug("Zalo API Err : " + ex.getErrorCode());
            log.Debug("Zalo API Mes : " + ex.getMessage());
            log.Debug(" ");
            log.Debug(" ");
        }
        catch (Exception ex)
        {
            log.Debug("Zalo API StackTrace : " + ex.StackTrace);
        }

        return(reValue);
    }