/// <summary>
        /// グループから退出する
        /// </summary>
        /// <param name="channelAccessToken">ChannelAccessToken</param>
        /// <param name="groupId">グループID</param>
        public static async Task LeaveGroup(
            string channelAccessToken,
            string groupId
            )
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                Trace.TraceWarning("Channel Access Token is Null");
            }
            if (groupId == null)
            {
                Trace.TraceWarning("Group Id is Null");
            }

            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["GroupUrl"] +
                groupId +
                ConfigurationManager.AppSettings["GroupLeaveUrl"];
            await MessagingApiSender.SendMessagingApi <string, string>(
                channelAccessToken,
                requestUrl,
                null,
                "post"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");
        }
        // TODO 認証済みLINE@アカウントまたは公式アカウントでないと確認できない
        /// <summary>
        /// グループメンバーのIdを取得する
        /// </summary>
        /// <param name="channelAccessToken">ChannelAccessToken</param>
        /// <param name="groupId">グループID</param>
        /// <param name="next">ユーザIDに続きがある場合に必要なキー</param>
        public static async Task <GetUserIdInGroupOrRoomMemberResponse> GetUserIdInGroupMember(
            string channelAccessToken,
            string groupId,
            string next = null
            )
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                Trace.TraceWarning("Channel Access Token is Null");
                return(null);
            }
            if (groupId == null)
            {
                Trace.TraceWarning("Group Id Of Get User Id In Group Member is Null");
                return(null);
            }

            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["GroupUrl"] +
                groupId +
                ConfigurationManager.AppSettings["GroupIdUrl"] +
                (next == null ? "" : ("?start=" + next));
            GetUserIdInGroupOrRoomMemberResponse response = await MessagingApiSender.SendMessagingApi <string, GetUserIdInGroupOrRoomMemberResponse>(
                channelAccessToken,
                requestUrl
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");

            return(response);
        }
Beispiel #3
0
        // TODO 未確認
        /// <summary>
        /// チャンネルアクセストークンを取り消す
        /// </summary>
        /// <param name="channelAccessToken">ChannelAccessToken</param>
        /// <returns>レスポンス</returns>
        public static async Task RevokeChannelAccessToken(string channelAccessToken)
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                System.Diagnostics.Trace.TraceWarning("Channel Access Token is Null");
                return;
            }

            RevokeChannelAccessTokenRequest request = new RevokeChannelAccessTokenRequest()
            {
                access_token = channelAccessToken
            };
            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["RevokeChannelAccessTokenUrl"];

            await MessagingApiSender.SendMessagingApi <RevokeChannelAccessTokenRequest, string>(
                null,
                requestUrl,
                request,
                "post",
                "application/x-www-form-urlencoded"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");
        }
Beispiel #4
0
        // TODO 取得できない
        /// <summary>
        /// チャンネルアクセストークンの発行
        /// </summary>
        /// <returns>レスポンス</returns>
        public static async Task <IssueChannelAccessTokenResponse> IssueChannelAccessToken()
        {
            Trace.TraceInformation("Start");

            IssueChannelAccessTokenRequest request = new IssueChannelAccessTokenRequest()
            {
                grant_type    = "client_credentials",
                client_id     = ConfigurationManager.AppSettings["ChannelId"],
                client_secret = ConfigurationManager.AppSettings["SecretChannelToken"]
            };
            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["IssueChannelAccessTokenUrl"];

            IssueChannelAccessTokenResponse response = await MessagingApiSender.SendMessagingApi <IssueChannelAccessTokenRequest, IssueChannelAccessTokenResponse>(
                null,
                requestUrl,
                request,
                "post",
                "application/x-www-form-urlencoded"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");

            return(response);
        }
Beispiel #5
0
        /// <summary>
        /// プロフィール情報取得
        /// </summary>
        /// <param name="channelAccessToken">チャンネルアクセストークン</param>
        /// <param name="userId">ユーザID</param>
        /// <returns>プロフィール情報</returns>
        public static async Task <GetProfileResponse> GetProfile(string channelAccessToken, string userId)
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                Trace.TraceWarning("Channel Access Token is Null");
                return(null);
            }
            if (userId == null)
            {
                Trace.TraceWarning("User Id is Null");
                return(null);
            }

            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["ProfileUrl"] +
                userId;

            GetProfileResponse response = await MessagingApiSender.SendMessagingApi <string, GetProfileResponse>(
                channelAccessToken,
                requestUrl
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");

            return(response);
        }
        /// <summary>
        /// ユーザから送られた画像や動画取得
        /// </summary>
        /// <param name="channelAccessToken">チャンネルアクセストークン</param>
        /// <param name="messageId">メッセージID</param>
        /// <returns>取得した画像や動画のバイナリ</returns>
        public static async Task <byte[]> GetContent(string channelAccessToken, string messageId)
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                Trace.TraceWarning("Channel Access Token is Null");
                return(null);
            }
            if (messageId == null)
            {
                Trace.TraceWarning("Message Id is Null");
                return(null);
            }

            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["GetContentUrlBefore"] +
                messageId +
                ConfigurationManager.AppSettings["GetContentUrlAfter"];

            byte[] response = await MessagingApiSender.SendMessagingApi <string>(channelAccessToken, requestUrl);

            Trace.TraceInformation("End");

            return(response);
        }
Beispiel #7
0
        public static async Task DeleteRichMenu(
            string channelAccessToken,
            string richMenuId
            )
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                Trace.TraceWarning("Channel Access Token is Null");
            }
            if (richMenuId == null)
            {
                Trace.TraceWarning("Rich Menu Id is Null");
            }

            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["RichMenuUrl"] +
                richMenuId;
            await MessagingApiSender.SendMessagingApi <CreateRichMenuRequest, string>(
                channelAccessToken,
                requestUrl,
                null,
                "delete"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");
        }
Beispiel #8
0
        /// <summary>
        /// 複数人同時プッシュ送信
        /// </summary>
        /// <param name="channelAccessToken">ChannelAccessToken</param>
        /// <param name="to">送信先IDの配列</param>
        /// <param name="messageFactoryService">MessageFactoryService</param>
        public static async Task SendMultiCastPushMessage(string channelAccessToken, string[] to, MessageFactoryService messageFactoryService)
        {
            Trace.TraceInformation("Start");

            MultiCastMessageRequest request = new MultiCastMessageRequest()
            {
                to       = to,
                messages = messageFactoryService.Messages
            };
            string requestUrl = ConfigurationManager.AppSettings["BaseUrl"] + ConfigurationManager.AppSettings["MultiCastUrl"];

            await MessagingApiSender.SendMessagingApi <MultiCastMessageRequest, string>(
                channelAccessToken,
                requestUrl,
                request,
                "post"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");
        }
        /// <summary>
        /// メッセージの返信
        /// </summary>
        /// <param name="channelAccessToken">ChannelAccessToken</param>
        /// <param name="replyToken">ReplyToken</param>
        /// <param name="messageFactoryService">MessageFactoryService</param>
        public static async Task SendReplyMessage(string channelAccessToken, string replyToken, MessageFactoryService messageFactoryService)
        {
            Trace.TraceInformation("Start");

            ReplyMessageRequest request = new ReplyMessageRequest()
            {
                replyToken = replyToken,
                messages   = messageFactoryService.Messages
            };
            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["ReplyUrl"];

            await MessagingApiSender.SendMessagingApi <ReplyMessageRequest, string>(
                channelAccessToken,
                requestUrl,
                request,
                "post"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");
        }
Beispiel #10
0
        public static async Task LinkUserAndRichMenu(
            string channelAccessToken,
            string userId,
            string richMenuId
            )
        {
            Trace.TraceInformation("Start");

            // 引数のnullチェック
            if (channelAccessToken == null)
            {
                Trace.TraceWarning("Channel Access Token is Null");
            }
            if (userId == null)
            {
                Trace.TraceWarning("User Id is Null");
            }
            if (richMenuId == null)
            {
                Trace.TraceWarning("Rich Menu Id is Null");
            }

            string requestUrl =
                ConfigurationManager.AppSettings["BaseUrl"] +
                ConfigurationManager.AppSettings["UserUrl"] +
                userId +
                ConfigurationManager.AppSettings["RichOnlyUrl"] +
                "/" +
                richMenuId;
            await MessagingApiSender.SendMessagingApi <string, GetUserRichMenuResponse>(
                channelAccessToken,
                requestUrl,
                null,
                "post"
                ).ConfigureAwait(false);

            Trace.TraceInformation("End");
        }