Beispiel #1
0
        public GetMediaItemResponse SendMediaItemRequest(GetMediaItemRequest request)
        {
            GetMediaItemResponse response = new GetMediaItemResponse();

            var rpcClient  = new XmlRpcRestClient(config.RequestUrl);
            var rpcRequest = new XmlRpcRestRequest(request.RequestUrl)
            {
                Method = Method.POST
            };

            // Add request parameters
            rpcRequest.AddXmlRpcBody(config.BlogID, config.Username, config.Password, request.Id);

            try
            {
                // Get response
                var rpcResponse = rpcClient.Execute <RpcResponseValue <string> >(rpcRequest);

                // Find and fill members in
                XmlMemberSearcher searcher = new XmlMemberSearcher(rpcResponse.Content);
                response.Link = searcher.GetValueOfMember("link");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }

            return(response);
        }
Beispiel #2
0
        public UploadFileResponse SendUploadFileRequest(UploadFileRequest request)
        {
            UploadFileResponse response = new UploadFileResponse();

            var rpcClient  = new XmlRpcRestClient(config.RequestUrl);
            var rpcRequest = new XmlRpcRestRequest(request.RequestUrl)
            {
                Method = Method.POST
            };

            // Add request parameters
            //rpcRequest.XmlSerializer = new XmlRpcSerializer("",false);
            rpcRequest.AddXmlRpcBody(config.BlogID, config.Username, config.Password, request.FileRequestStruct, "true", "false");

            try
            {
                // Get response
                var rpcResponse = rpcClient.Execute <RpcResponseValue <string> >(rpcRequest);

                // Find and fill members in
                XmlMemberSearcher searcher = new XmlMemberSearcher(rpcResponse.Content);
                response.FileResponseStruct.Id       = Convert.ToInt32(searcher.GetValueOfMember("id"));
                response.FileResponseStruct.Url      = searcher.GetValueOfMember("url");
                response.FileResponseStruct.File     = searcher.GetValueOfMember("file");
                response.FileResponseStruct.FileType = searcher.GetValueOfMember("type");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }

            return(response);
        }
Beispiel #3
0
        public GetProfileResponse SendGetProfileRequest(GetProfileRequest request)
        {
            GetProfileResponse response = new GetProfileResponse();

            var rpcClient  = new XmlRpcRestClient(config.RequestUrl);
            var rpcRequest = new XmlRpcRestRequest(request.RequestUrl)
            {
                Method = Method.POST
            };

            // Add request parameters
            rpcRequest.AddXmlRpcBody(config.BlogID, config.Username, config.Password);

            try
            {
                // Get response
                var rpcResponse = rpcClient.Execute <RpcResponseValue <string> >(rpcRequest);

                Console.WriteLine("RESPONSE:");
                Console.WriteLine(rpcResponse.Content);

                // Find and fill members in
                XmlMemberSearcher searcher = new XmlMemberSearcher(rpcResponse.Content);
                response.Bio         = searcher.GetValueOfMember("bio");
                response.DisplayName = searcher.GetValueOfMember("display_name");
                response.Email       = searcher.GetValueOfMember("email");
                response.FirstName   = searcher.GetValueOfMember("first_name");
                response.LastName    = searcher.GetValueOfMember("last_name");
                response.NiceName    = searcher.GetValueOfMember("nicename");
                response.Nickname    = searcher.GetValueOfMember("nickname");
                response.Url         = searcher.GetValueOfMember("url");
                response.UserId      = searcher.GetValueOfMember("user_id");
                response.Username    = searcher.GetValueOfMember("username");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }

            return(response);
        }