• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# OAuth.ConsumerBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DotNetOpenAuth.OAuth.ConsumerBase的典型用法代码示例。如果您正苦于以下问题:C# ConsumerBase类的具体用法?C# ConsumerBase怎么用?C# ConsumerBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ConsumerBase类属于DotNetOpenAuth.OAuth命名空间,在下文中一共展示了ConsumerBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UpdateProfileImage

		public static XDocument UpdateProfileImage(ConsumerBase twitter, string accessToken, Stream image, string contentType) {
			var parts = new[] {
				MultipartPostPart.CreateFormFilePart("image", "twitterPhoto", contentType, image),
			};
			HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateProfileImageEndpoint, accessToken, parts);
			IncomingWebResponse response = twitter.Channel.WebRequestHandler.GetResponse(request);
			string responseString = response.GetResponseReader().ReadToEnd();
			return XDocument.Parse(responseString);
		}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:9,代码来源:TwitterConsumer.cs


示例2: OAuthAuthorization

        /// <summary>
        /// Initializes a new instance of the <see cref="OAuthAuthorization"/> class.
        /// </summary>
        /// <param name="consumer">The consumer.</param>
        protected OAuthAuthorization(ConsumerBase consumer)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }

            this.Consumer = consumer;
        }
开发者ID:paulirwin,项目名称:LinkedInDeveloperToolkit,代码行数:13,代码来源:OAuthAuthorization.cs


示例3: UpdateStatus

        public static XDocument UpdateStatus(ConsumerBase twitter, string accessToken, string message)
        {
            var data = new Dictionary<string, string>();
            data.Add("status", message);

            HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateStatusEndpoint, accessToken, data);

            var response = twitter.Channel.WebRequestHandler.GetResponse(request);
            return XDocument.Load(XmlReader.Create(response.GetResponseReader()));
        }
开发者ID:micahlmartin,项目名称:WikipediaMaze,代码行数:10,代码来源:TwitterConsumer.cs


示例4: UpdateProfileBackgroundImage

		public static XDocument UpdateProfileBackgroundImage(ConsumerBase twitter, string accessToken, string image, bool tile) {
			var parts = new[] {
				MultipartPostPart.CreateFormFilePart("image", image, "image/" + Path.GetExtension(image).Substring(1).ToLowerInvariant()),
				MultipartPostPart.CreateFormPart("tile", tile.ToString().ToLowerInvariant()),
			};
			HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateProfileBackgroundImageEndpoint, accessToken, parts);
			request.ServicePoint.Expect100Continue = false;
			IncomingWebResponse response = twitter.Channel.WebRequestHandler.GetResponse(request);
			string responseString = response.GetResponseReader().ReadToEnd();
			return XDocument.Parse(responseString);
		}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:11,代码来源:TwitterConsumer.cs


示例5: GetProfile

        public static string GetProfile(ConsumerBase consumer, string accessToken)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }

            var request = consumer.PrepareAuthorizedRequest(ProfileEndpoint, accessToken, new Dictionary<string, string>());
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            return body;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:12,代码来源:LinkedInConsumer.cs


示例6: GetUser

        /// <summary>
        /// Gets the current oDesk user.
        /// </summary>
        /// <param name="consumer">The oDesk consumer.</param>
        /// <param name="accessToken">The access token previously retrieved.</param>
        /// <returns>An XML document returned by oDesk.</returns>
        public static XDocument GetUser(ConsumerBase consumer, string accessToken)
        {
            if (consumer == null)
                throw new ArgumentNullException("consumer");

            var request = consumer.PrepareAuthorizedRequest(GetUserEndpoint, accessToken);

            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            var body = response.GetResponseReader().ReadToEnd();
            var result = XDocument.Parse(body);
            return result;
        }
开发者ID:daniel-sim,项目名称:oDesk-API-C--library,代码行数:18,代码来源:ODeskConsumer.cs


示例7: GetDigs

        public static string GetDigs(ConsumerBase consumer, string accessToken, string id)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }

            var extraData = new Dictionary<string, string>() {
				{ "story_id", id }
			};
            var request = consumer.PrepareAuthorizedRequest(GetDiggsEndpoint, accessToken, extraData);
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            return body;
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:15,代码来源:DiggConsumer.cs


示例8: GetDoc

	    public static Stream GetDoc(ConsumerBase consumer, string accessToken, string docEndpoint, out long size)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }
            var endpoint = new MessageReceivingEndpoint(docEndpoint, HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
            var extraData = new Dictionary<string, string>() /*{ {"GData-Version","3.0"} }*/;
            var request = consumer.PrepareAuthorizedRequest(endpoint, accessToken, extraData);
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            if (!string.IsNullOrEmpty(response.Headers[HttpResponseHeader.ContentLength]))
            {
                long.TryParse(response.Headers[HttpResponseHeader.ContentLength], out size);
            }
            else
            {
                size = 0;
            }
            return response.ResponseStream;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:20,代码来源:GoogleConsumer.cs


示例9: GetDocList

	    public static XDocument GetDocList(ConsumerBase consumer, string accessToken, string nextEndpoint)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }
            var endpoint = GetDocsEntriesEndpoint;
            if (!string.IsNullOrEmpty(nextEndpoint))
            {
                endpoint = new MessageReceivingEndpoint(nextEndpoint, HttpDeliveryMethods.GetRequest);
            }

            var extraData = new Dictionary<string, string>() /*{ {"GData-Version","3.0"} }*/;
            //var request = consumer.PrepareAuthorizedRequest(endpoint, accessToken, extraData);
            //var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            //string body = response.GetResponseReader().ReadToEnd();
            //XDocument result = XDocument.Parse(body);
            //return result;

            var request = consumer.PrepareAuthorizedRequest(endpoint, accessToken, extraData);

            // Enable gzip compression.  Google only compresses the response for recognized user agent headers. - Mike Lim
            request.AutomaticDecompression = DecompressionMethods.GZip;
            request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16";

            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            XDocument result = XDocument.Parse(body);
            return result;

        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:31,代码来源:GoogleConsumer.cs


示例10: GetContacts

        /// <summary>
        /// Gets the Gmail address book's contents.
        /// </summary>
        /// <param name="consumer">The Google consumer previously constructed using <see cref="CreateWebConsumer"/> or <see cref="CreateDesktopConsumer"/>.</param>
        /// <param name="accessToken">The access token previously retrieved.</param>
        /// <returns>An XML document returned by Google.</returns>
        public static XDocument GetContacts(ConsumerBase consumer, string accessToken)
        {
            if (consumer == null) {
                throw new ArgumentNullException("consumer");
            }

            var response = consumer.PrepareAuthorizedRequestAndSend(GetContactsEndpoint, accessToken);
            string body = response.GetResponseReader().ReadToEnd();
            XDocument result = XDocument.Parse(body);
            return result;
        }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:17,代码来源:GoogleConsumer.cs


示例11: YDResourceAPI

 public YDResourceAPI(ConsumerBase consumer, string accessToken)
     : base(consumer, accessToken)
 {
 }
开发者ID:asd1355215911,项目名称:ydnoteopenapi4n,代码行数:4,代码来源:YDResourceAPI.cs


示例12: YDBaseAPI

 public YDBaseAPI(ConsumerBase consumer,string accessToken)
 {
     _consumer = consumer;
     _tokenManager = consumer.TokenManager;
     _accessToken = accessToken;
 }
开发者ID:asd1355215911,项目名称:ydnoteopenapi4n,代码行数:6,代码来源:YDBaseAPI.cs


示例13: GetContacts

        /// <summary>
        /// Gets the Gmail address book's contents.
        /// </summary>
        /// <param name="consumer">The Google consumer.</param>
        /// <param name="accessToken">The access token previously retrieved.</param>
        /// <param name="maxResults">The maximum number of entries to return. If you want to receive all of the contacts, rather than only the default maximum, you can specify a very large number here.</param>
        /// <param name="startIndex">The 1-based index of the first result to be retrieved (for paging).</param>
        /// <returns>An XML document returned by Google.</returns>
        public static XDocument GetContacts(ConsumerBase consumer, string accessToken, int maxResults/* = 25*/, int startIndex/* = 1*/)
        {
            if (consumer == null) {
                throw new ArgumentNullException("consumer");
            }

            var extraData = new Dictionary<string, string>() {
                { "start-index", startIndex.ToString(CultureInfo.InvariantCulture) },
                { "max-results", maxResults.ToString(CultureInfo.InvariantCulture) },
            };
            var request = consumer.PrepareAuthorizedRequest(GetContactsEndpoint, accessToken, extraData);
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            XDocument result = XDocument.Parse(body);
            return result;
        }
开发者ID:trayburn,项目名称:Presentation-FiveLibs,代码行数:24,代码来源:GoogleConsumer.cs


示例14: GetMyContacts

        /// <summary>
        /// Gets the Xing adress book's contents.
        /// </summary>
        /// <param name="consumer">The Xing consumer.</param>
        /// <param name="accessToken">The access token previously retrieved.</param>
        /// <param name="maxResults">The maximum number of entries to return. If you want to receive all of the contacts, rather than only the default maximum, you can specify a very large number here.</param>
        /// <param name="startIndex">The 1-based index of the first result to be retrieved (for paging).</param>
        /// <param name="field">user_fields of info on https://dev.xing.com/docs/get/users/:id </param>
        /// <returns>An dynamic Object returned by Xing.</returns>
        public static Object GetMyContacts(ConsumerBase consumer, string accessToken, string field, int maxResults/* = 25*/, int startIndex/* = 1*/)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }
            var extraData = new Dictionary<string, string>() {
                { "offset", startIndex.ToString(CultureInfo.InvariantCulture) },
                { "limit", maxResults.ToString(CultureInfo.InvariantCulture) },
                { "user_fields",field },
            };
            var request = consumer.PrepareAuthorizedRequest(GetContactsEndpoint, accessToken, extraData);

            //request.AutomaticDecompression = DecompressionMethods.GZip;
            request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16";
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            var serializer = new JavaScriptSerializer();
            serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
            dynamic obj = serializer.Deserialize(body, typeof(object));
            return obj;
        }
开发者ID:zwisler,项目名称:DotNetOpenAuth-Xing-Client,代码行数:31,代码来源:XingClient.cs


示例15: UpdateProfileImage

 public static XDocument UpdateProfileImage(ConsumerBase twitter, string accessToken, string pathToImage)
 {
     string contentType = "image/" + Path.GetExtension(pathToImage).Substring(1).ToLowerInvariant();
     return UpdateProfileImage(twitter, accessToken, File.OpenRead(pathToImage), contentType);
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:5,代码来源:TwitterConsumer.cs


示例16: GetUsername

 public static string GetUsername(ConsumerBase twitter, string accessToken)
 {
     XDocument xml = VerifyCredentials(twitter, accessToken);
     XPathNavigator nav = xml.CreateNavigator();
     return nav.SelectSingleNode("/user/screen_name").Value;
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:6,代码来源:TwitterConsumer.cs


示例17: UpdateStatus

        /// <summary>
        ///    Updates the authenticating user's status, also known as tweeting.
        /// </summary>
        /// <param name="twitter"></param>
        /// <param name="accessToken"></param>
        /// <param name="status">The text of your status update, typically up to 140 characters. URL encode as necessary. t.co link wrapping may effect character counts.</param>
        /// <param name="includeEntities">When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.
        ///  </param>
        /// <returns></returns>
        public static JObject UpdateStatus(ConsumerBase twitter, string accessToken, String status, bool includeEntities)
        {

            var parts = new[] {
				MultipartPostPart.CreateFormPart("status", status),
                MultipartPostPart.CreateFormPart("include_entities", includeEntities.ToString()),
			};

            HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateStatusEndpoint, accessToken, parts);
            IncomingWebResponse response = twitter.Channel.WebRequestHandler.GetResponse(request);
          
            using (var responseReader = response.GetResponseReader())
            {
                var result = responseReader.ReadToEnd();

                return JObject.Parse(result);

            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:28,代码来源:TwitterConsumer.cs


示例18: YQL

        public static XDocument YQL(ConsumerBase consumer, string accessToken, string yql)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }

            yql = yql.Replace("'", "\"");
            string uri = "http://query.yahooapis.com/v1/yql?q=" + HttpUtility.UrlEncode(yql).Replace("+", "%20").Replace("*", "%2A").Replace("(", "%28").Replace(")", "%29");

            MessageReceivingEndpoint endPoint = new MessageReceivingEndpoint(uri, HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest);

            var request = consumer.PrepareAuthorizedRequest(endPoint, accessToken);
            string header = request.Headers.GetValues(0)[0];
            header = header.Replace("OAuth", "").Replace("\"", "").Replace(",", "&").Trim();
            uri += "&" + header;

            HttpWebRequest req = (HttpWebRequest) WebRequest.Create(uri);
            req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5";
            WebResponse resp = req.GetResponse();
            Encoding enc = System.Text.Encoding.GetEncoding(1252);
            StreamReader loResponseStream = new
            StreamReader(resp.GetResponseStream(), enc);
            string body = loResponseStream.ReadToEnd();

            return XDocument.Parse(body);
        }
开发者ID:yahoo,项目名称:yos-social-demo-dotnet,代码行数:27,代码来源:YahooConsumer.cs


示例19: PostStatus

 /// <summary>
 /// Post a Status Messages.
 /// </summary>
 /// <param name="consumer">The Xing consumer.</param>
 /// <param name="accessToken">The access token previously retrieved.</param>
 /// <param name="message">The new status update. The maximum length is 420 characters.</param>       
 ///  <param name="user_id">ID of the user starting the conversation.</param>
 /// <returns>An dynamic Object returned by Xing.</returns>
 public static bool PostStatus(ConsumerBase consumer, string accessToken, string message,  string user_id)
 {
     if (consumer == null)
     {
         throw new ArgumentNullException("consumer");
     }
     var extraData = new Dictionary<string, string>() {
         { "message", message },
     };
     MessageReceivingEndpoint Endpoint = new MessageReceivingEndpoint("https://api.xing.com/v1/users/" + user_id + "/status_message", HttpDeliveryMethods.PostRequest);
     var request = consumer.PrepareAuthorizedRequest(Endpoint, accessToken, extraData);
     //request.AutomaticDecompression = DecompressionMethods.GZip;
     request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16";
     var response = consumer.Channel.WebRequestHandler.GetResponse(request);
     string body = response.GetResponseReader().ReadToEnd();
     if (body.Contains("has been posted")) return true;
     else return false;
 }
开发者ID:zwisler,项目名称:DotNetOpenAuth-Xing-Client,代码行数:26,代码来源:XingClient.cs


示例20: PostConversation

        /// <summary>
        /// Post a Conversation.
        /// </summary>
        /// <param name="consumer">The Xing consumer.</param>
        /// <param name="accessToken">The access token previously retrieved.</param>
        /// <param name="content">Message text. Max. size is 16384 UTF-8 characters.</param>
        /// <param name="recipient_ids">Comma-separated list of recipients. There must be at least one recipient. Sender cannot be included.</param>
        ///  <param name="subject">Subject for conversation. Max. size is 32 UTF-8 characters</param>
        ///  <param name="user_id">ID of the user starting the conversation.</param>
        /// <returns>An dynamic Object returned by Xing.</returns> 
        public static Object PostConversation(ConsumerBase consumer, string accessToken, string content, string recipient_ids, string subject, string user_id)
        {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }
            var extraData = new Dictionary<string, string>() {
                { "content", content },
                { "recipient_ids", recipient_ids },
                { "subject", subject },
            };
            MessageReceivingEndpoint Endpoint = new MessageReceivingEndpoint("https://api.xing.com/v1/users/" + user_id + "/conversations", HttpDeliveryMethods.PostRequest);
            var request = consumer.PrepareAuthorizedRequest(Endpoint, accessToken, extraData);

            //request.AutomaticDecompression = DecompressionMethods.GZip;
            request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16";
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            var serializer = new JavaScriptSerializer();
            serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
            dynamic obj = serializer.Deserialize(body, typeof(object));
            return obj;
        }
开发者ID:zwisler,项目名称:DotNetOpenAuth-Xing-Client,代码行数:33,代码来源:XingClient.cs



注:本文中的DotNetOpenAuth.OAuth.ConsumerBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Messages.UnauthorizedTokenRequest类代码示例发布时间:2022-05-24
下一篇:
C# Messaging.MessageReceivingEndpoint类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap