Built query with additional parameters return empty result


#1

Hello friends,

code below is working when I use just one parameter in the query and true results are fetched from twitter search api.
But, when I tried to build a query with additional parameters then I am getting empty results and twitter answer is below:

twitter answer:
{“statuses”:[],“search_metadata”:{“completed_in”:0.018,“max_id”:439490100654002176,“max_id_str”:“439490100654002176”,“query”:“ferrari%26lang%3Dtr”,“refresh_url”:"?since_id=439490100654002176&q=ferrari%26lang%3Dtr&include_entities=1",“count”:15,“since_id”:0,“since_id_str”:“0”}}

For example;

working query that was built in my application is: https://api.twitter.com/1.1/search/tweets.json?q=ferrari (it works perfect)
not working query is: https://api.twitter.com/1.1/search/tweets.json?q=ferrari%26lang%3Dtr (encoded query, this query returns answer above)

WHAT IS THE PROBLEM MY FRIENDS?

void getTweets(string resource_url, string q)
{
// oauth application keys

        var oauth_token = "aaa";
        var oauth_token_secret = "bbb";
        var oauth_consumer_key = "ccc";
        var oauth_consumer_secret = "ddd";

        // 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();


        // create oauth signature
        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 = "q=" + Uri.EscapeDataString(q);//
        resource_url += "?" + postBody;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);

        richQuery.Text = resource_url;

        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();

        //application specific codes here

}

in main there are just two lines

…query is being built here…

string url = “https://api.twitter.com/1.1/search/tweets.json”;
getTweets (url, query);