Пример #1
0
 public void SetEndpointPresence()
 {
     httpClient.SendPut(SkypeApiUrls.EndpointPresenceUrl(messagesHost, endpointId),
                        JObject.FromObject(new
     {
         id          = "messagingService",
         type        = "EndpointPresenceDoc",
         selfLink    = "uri",
         privateInfo = new
         {
             epname = "skype"
         },
         publicInfo = new
         {
             capabilities     = "",
             type             = 1,
             typ              = 1,
             skypeNameVersion = SkypeConstants.SkypewebClientinfoVersion + "/" + SkypeConstants.SkypewebClientinfoName,
             nodeInfo         = "xx",
             version          = SkypeConstants.SkypewebClientinfoVersion
         }
     }),
                        new Dictionary <string, string>
     {
         { "RegistrationToken", registrationToken }
     });
 }
Пример #2
0
 public void GetConversations()
 {
     var response = httpClient.SendGet(SkypeApiUrls.ConversationsUrl(messagesHost),
                                       new Dictionary <string, string>
     {
         { "RegistrationToken", registrationToken }
     });
 }
Пример #3
0
 public void SetPresence(string status)
 {
     httpClient.SendPut(SkypeApiUrls.PresenceUrl(messagesHost),
                        JObject.FromObject(new
     {
         status = status
     }),
                        new Dictionary <string, string>
     {
         { "RegistrationToken", registrationToken }
     });
 }
Пример #4
0
        public void SetConsumptionHorizon(string conversation, string originalArrivalTime, string clientMessageId)
        {
            string consumptionhorizon = originalArrivalTime + ";" + 0 + ";" + clientMessageId;

            httpClient.SendPut(SkypeApiUrls.ConversationConsumptionHorizonUrl(messagesHost, conversation),
                               JObject.FromObject(new
            {
                consumptionhorizon = consumptionhorizon
            }),
                               new Dictionary <string, string>
            {
                { "RegistrationToken", registrationToken }
            });
        }
Пример #5
0
 public void SendMessage(string conversation, string content)
 {
     httpClient.SendPost(SkypeApiUrls.ConversationMessagesUrl(messagesHost, conversation),
                         JObject.FromObject(new
     {
         clientmessageid = "",
         content         = content,
         messagetype     = "RichText",
         contenttype     = "text"
     }),
                         new Dictionary <string, string>
     {
         { "RegistrationToken", registrationToken }
     });
 }
Пример #6
0
        public SkypePoll PollSubscription(int subscription)
        {
            var response = httpClient.SendPost(SkypeApiUrls.PollSubscriptionUrl(messagesHost, subscription),
                                               "", "application/json",
                                               new Dictionary <string, string>
            {
                { "RegistrationToken", registrationToken }
            });

            if (String.IsNullOrEmpty(response.ResponseData))
            {
                return(null);
            }
            return(JsonConvert.DeserializeObject <SkypePoll>(response.ResponseData));
        }
Пример #7
0
        public SkypeAuthParams Login(LoginCredentials credentials)
        {
            var response = httpClient.SendGet(SkypeApiUrls.WebLoginUrl);

            var postParameters = GetPostParameters(response.ResponseData);

            postParameters.Add("username", credentials.UserName);
            postParameters.Add("password", credentials.Password);

            var loginUrl = SkypeApiUrls.WebLoginUrlWithQuery(postParameters["client_id"]);

            response = httpClient.SendPost(loginUrl, postParameters);

            var authParams = new SkypeAuthParams {
                Token = GetToken(response.ResponseData)
            };

            var customHeaders = new Dictionary <string, string>();

            customHeaders["LockAndKey"] = GetLockAndKey();

            customHeaders["ClientInfo"] = GetClientInfo();

            customHeaders["Authentication"] = "skypetoken=" + authParams.Token;

            response =
                httpClient.SendPost(SkypeApiUrls.EndpointsUrl, new JObject(), customHeaders);

            if (response.ResponseHeaders.ContainsKey("Set-RegistrationToken"))
            {
                authParams.RegistrationToken = ParseRegistrationToken(response.ResponseHeaders["Set-RegistrationToken"]);
                authParams.EndpointId        = ParseEndpointId(response.ResponseHeaders["Set-RegistrationToken"]);
                // the endpoint post may be redirected to another server, in which case we need to use that
                // in subsequent requests
                authParams.MessagesHost = response.ResponseUrl.Host;
            }

            return(authParams);
        }
Пример #8
0
        public int CreateSubscription()
        {
            var response = httpClient.SendPost(SkypeApiUrls.SubscriptionsUrl(messagesHost),
                                               JObject.FromObject(new
            {
                channelType         = "httpLongPoll",
                interestedResources = new string[]
                {
                    "/v1/users/ME/conversations/ALL/properties",
                    "/v1/users/ME/conversations/ALL/messages",
                    "/v1/users/ME/contacts/ALL",
                    "/v1/threads/ALL"
                },
                template = "raw"
            }),
                                               new Dictionary <string, string>
            {
                { "RegistrationToken", registrationToken }
            });
            string location = response.ResponseHeaders["Location"];

            return(int.Parse(location.Substring(location.LastIndexOf('/') + 1)));
        }
Пример #9
0
 public void AcceptAuthRequest(string skypeName)
 {
     httpClient.SendPut(SkypeApiUrls.AcceptAuthRequestUrl(skypeName));
 }
Пример #10
0
 public IEnumerable <SkypeProfile> SearchContacts(string query)
 {
     return(SendAndDeserialize <IEnumerable <SkypeProfile> >(SkypeApiUrls.SearchContactsUrlWithQuery(query), new SkypeProfileConverter()));
 }