Migrating from twitter api 1.0 to 1.1


#1

when iam trying to get the user details
https://api.twitter.com/1.1/users/show.json?screen_name=rsarver
iam getting 502 bad gateway error
i used oauth tool and i passed all the keys but getting 401 unauthorized error please check my code once

protected void Page_Load(object sender, EventArgs e)
{

        string query = "taruni " + "chitturi";

        string url = "https://api.twitter.com/1.1/users/show.json";

        findUserTwitter(url, query);


    }

    public void findUserTwitter(string resource_url, string q)
    {


        var oauth_token = ConfigurationManager.AppSettings["AccessToken"];

        var oauth_token_secret = ConfigurationManager.AppSettings["AccessTokenSecret"];

        var oauth_consumer_key = ConfigurationManager.AppSettings["ConsumerKey"];

        var oauth_consumer_secret = ConfigurationManager.AppSettings["ConsumerSecret"];// = "insert here...";



        // oauth implementation details

        var oauth_version = "1.0";

        var oauth_signature_method = "HMAC-SHA1";



        // unique request details

        var oauth_nonce = Convert.ToBase64String(

            new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));

        var timeSpan = DateTime.UtcNow

            - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

        var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();



        var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +

                        "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&q={6}";



        var baseString = string.Format(baseFormat,

                                    oauth_consumer_key,

                                    oauth_nonce,

                                    oauth_signature_method,

                                    oauth_timestamp,

                                    oauth_token,

                                    oauth_version,

                                    Uri.EscapeDataString(q)

                                    );



        baseString = string.Concat("GET&", Uri.EscapeDataString(resource_url), "&", Uri.EscapeDataString(baseString));



        var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),

                                "&", Uri.EscapeDataString(oauth_token_secret));



        string oauth_signature;

        using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
        {

            oauth_signature = Convert.ToBase64String(

                hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));

        }



        // create the request header

        var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +

                           "oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +

                           "oauth_token=\"{4}\", oauth_signature=\"{5}\", " +

                           "oauth_version=\"{6}\"";



        var authHeader = string.Format(headerFormat,

                                Uri.EscapeDataString(oauth_nonce),

                                Uri.EscapeDataString(oauth_signature_method),

                                Uri.EscapeDataString(oauth_timestamp),

                                Uri.EscapeDataString(oauth_consumer_key),

                                Uri.EscapeDataString(oauth_token),

                                Uri.EscapeDataString(oauth_signature),

                                Uri.EscapeDataString(oauth_version)

                        );







        ServicePointManager.Expect100Continue = false;



        // make the request

        var postBody = "screen_name=" + Uri.EscapeDataString(q);//

        resource_url += "?" + postBody;

        System.Net.WebProxy rssProxy = new System.Net.WebProxy("instpisa1", 8080);
        rssProxy.Credentials = new System.Net.NetworkCredential("tchitturi", "sierra$123321", "in");

        // bypass the proxy on local network
        rssProxy.BypassProxyOnLocal = true;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
       
        // assign the proxy to the request
        request.Proxy = rssProxy;

        

        request.Headers.Add("Authorization", authHeader);

        request.Method = "GET";

        request.ContentType = "application/x-www-form-urlencoded";

       var  response = (HttpWebResponse)request.GetResponse();
        
       var reader = new StreamReader(response.GetResponseStream());
        
       var objText = reader.ReadToEnd();
       //XmlDocument objXmlDoc = new XmlDocument();
       //UserMetrics objUserMetrics = new UserMetrics();
        
       //objXmlDoc.LoadXml(objText);
        
       //if (objXmlDoc.GetElementsByTagName("name").Count > 0)
       //{
       //    objUserMetrics.Name = objXmlDoc.GetElementsByTagName("name").Item(0).InnerText;
       //}
       //lblName.Text = objUserMetrics.Name;
        myDiv.InnerHtml =objText;/**/

when i used search.json,its works fine but getting error with show.json,daily.json