cn.jpush.api/report/ReportClient.cs

(开头部分) 4KB

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

using cn.jpush.api.common;
using cn.jpush.api.util;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace cn.jpush.api.report
{
    class ReportClient:BaseHttpClient
    {
        private  const String REPORT_HOST_NAME = "https://report.jpush.cn";
        private  const String REPORT_RECEIVE_PATH = "/v2/received";
        private const String REPORT_RECEIVE_PATH_V3 = "/v3/received";
        private const String REPORT_USER_PATH = "/v3/users";

        private String appKey;
        private String masterSecret;
        public ReportClient(String appKey, String masterSecret) 
        {
            this.appKey = appKey;
            this.masterSecret = masterSecret;        
        }
        public ReceivedResult getReceiveds(String msg_ids) 
        {
            checkMsgids(msg_ids);
            return getReceiveds_common(msg_ids, REPORT_RECEIVE_PATH);
        }
        public ReceivedResult getReceiveds_v3(String msg_ids)
        {
            checkMsgids(msg_ids);
            return getReceiveds_common(msg_ids, REPORT_RECEIVE_PATH_V3);
        }
        public  UsersResult    getUsers(TimeUnit timeUnit, String start, int duration)
        {
            String url = REPORT_HOST_NAME + REPORT_USER_PATH
                    + "?time_unit=" + timeUnit.ToString()
                    + "&start=" + start + "&duration=" + duration;
            String auth = Base64.getBase64Encode(this.appKey + ":" + this.masterSecret);
            ResponseWrapper response = this.sendGet(url, auth, null);

            return UsersResult.fromResponse(response);
        }
        public MessagesResult getReportMessages(params String[] msgIds)
        {
            return getReportMessages(StringUtil.arrayToString(msgIds));
        }
        public String checkMsgids(String msgIds)
        {

            if (string.IsNullOrEmpty(msgIds)) {
                throw new ArgumentException("msgIds param is required.");
            }
            Regex reg = new Regex(@"[^0-9, ]");
            if(reg.IsMatch(msgIds))
            {
                  throw new ArgumentException("msgIds param format is incorrect. "
                        + "It should be msg_id (number) which response from JPush Push API. "
                        + "If there are many, use ',' as interval. ");
            }
            msgIds = msgIds.Trim();
后面还有 54 行代码,购买后查看完整代码

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

AI 解读

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

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