OAuth.OAuthConsumer.request C# (CSharp) Method

request() public method

public request ( string url, string httpMethod, List parameters, string responseFormat ) : Object
url string
httpMethod string
parameters List
responseFormat string
return Object
        public Object request(string url, string httpMethod, List<QueryParameter> parameters, string responseFormat)
        {
            string oauth_token = this._oauthConfig.OauthToken;
            string oauth_token_secret = this._oauthConfig.OauthTokenSecret;
            OAuthRequest request = new OAuthRequest(this, base._debugType);
            string response = request.request(new Uri(url), httpMethod, oauth_token, oauth_token_secret, parameters).ToString();
            if (response == String.Empty || response.Length == 0)
            {
                base._debug("The Request Response was empty");
                return null;
            }
            Object result = null;

            switch (responseFormat)
            {
                case "DataSet":
                    System.IO.StringReader strreader = new System.IO.StringReader(response);
                    DataSet ds = new DataSet();
                    ds.ReadXml(strreader);
                    result = ds;
                    break;
                case "XML":
                    System.IO.StringReader strxmlreader = new System.IO.StringReader(response);
                    XmlTextReader xmlReader = new XmlTextReader(strxmlreader);
                    xmlReader.Read();
                    result = xmlReader;
                    break;
                case "PLAIN":
                default:
                    result = response;
                    break;
            }
            return result;
        }

Usage Example

示例#1
0
文件: Main.cs 项目: possan/sharpOAuth
        /// <summary>
        /// With this test, the application will request an oauth_access token for the current user. The user will have to authorize the app (this code sample) to access his twitter account.
        /// A combination of keys will be generated for him : an oauth access token.
        /// </summary>
        public void test_twitterOauthClient()
        {
            // Create an OAuth config
            OAuthConfig oauthConfig = new OAuthConfig("console");
            oauthConfig.SiteUrl = "http://www.worldgoneweb.com";
            oauthConfig.OauthVersion = "1.0";
            oauthConfig.OauthSignatureMethod = "HMAC-SHA1";
            oauthConfig.ConsumerKey = TwitterOAuthTest._consumerKey;
            oauthConfig.ConsumerSecret = TwitterOAuthTest._consumerSecret;
            oauthConfig.RequestTokenUrl = "https://api.twitter.com/oauth/request_token";
            oauthConfig.AccessTokenUrl = "https://api.twitter.com/oauth/access_token";
            oauthConfig.UserAuthorizationUrl = "https://api.twitter.com/oauth/authorize";

            // Create an OAuth consumer
            OAuthConsumer oauthConsumer = new OAuthConsumer(oauthConfig, "console");

            // Request Token
            oauthConsumer.getRequestToken();

            // Enter the Pin Code
            Console.WriteLine("Enter the pin code:");
            string pincode = Console.ReadLine();

            // Request Access Token
            oauthConsumer.getAccessToken(pincode);

            // Make an API Call (call the home_timeline status) and debug the response
            string response = (string)oauthConsumer.request("http://api.twitter.com/1/statuses/home_timeline.xml", "GET", null, "PLAIN");
            Console.WriteLine(response);
        }
All Usage Examples Of OAuth.OAuthConsumer::request