Thank you for your response. I'll run the lines to look at this further. The 
confusion is as whether "Query string" refers to HTTP query string (? until 
end) or the Twitter API "query" (?q=<value>) value w/operators and parameters?


Usage Notes:
        * Query strings should be URL encoded.
        * Queries are limited 140 URL encoded characters."
When I check this against the Advanced Search Tool, it wasn't clear what was 
being included. And the tools seems to be somewhat buggy.


From: Scott Haneda <>
Sent: Sat, October 17, 2009 9:22:44 PM
Subject: [twitter-dev] Re: What is included In the "Queries are limited 140 URL 
encoded  characters." restriction?

I am not sure I understand the confusion, the API is 140 characters exactly in 
the query string.  You can run this, don't run it often, or put a sleep 1; in 
the loop if you do.


# This script assumes you pre url encode your data.
# Request url

for (( i = 1; i < 200; i++ )); do
     # Current position/length
     echo "Query Length: "$i;

     # Shove on another character

     # The url we are about to poke
     echo $URL$j

     RESULT=$( curl -o /dev/null -s -w "%{http_code} %{size_request}" {$URL$j} )

     # Show http_code
     http_code=`echo $RESULT | awk '{print $1}'`
     echo http_code: $http_code
     # Show size_request
     size_request=`echo $RESULT | awk '{print $2}'`
     echo size_request: $size_request \(Sent bytes\)

     echo ""

Here is a snip of the results, from the first, to the last bits around 140, 
right when you hit 141, it goes from http 200, to http 403.  Though this script 
should make it rather easy to test what happens with url encoded characters.  I 
do not think it matters, each character is a character, so if it is a space, 
that will get url encoded into %20 taking up three characters.

Query Length: 1
http_code: 200
size_request: 163 (Sent bytes)


Query Length: 138
http_code: 200
size_request: 300 (Sent bytes)

Query Length: 139
http_code: 200
size_request: 301 (Sent bytes)

Query Length: 140
http_code: 200
size_request: 302 (Sent bytes)

Query Length: 141
http_code: 403
size_request: 303 (Sent bytes)

Query Length: 142
http_code: 403
size_request: 304 (Sent bytes)
--Scott * If you contact me off list replace talklists@ with scott@ *

On Oct 17, 2009, at 7:39 PM, leonspencer wrote:

> And still waiting on a response. More information from a associate:
> Subject: Re: Do you know what is being counted toward "query length"
> Yeah, because your using twitter search and not api!
> An Api String would be
> For Geo Locations
> Or
> For Since...
> On Oct 17, 2:29 pm, leonspencer <> wrote:
>> Still waiting for a response here. I tried a query with the Twitter
>> Advanced Search 
>> tool:
>> When I strip away the parameter names and operators, this is the
>> values stringed together:
>> AllofthesewordsThisexactphraseAnyofthesewordsNoneofthesewordsThishashtagenleonspencerleonspencerleonspencer15mi2009-10-072009-10-1815
>> Length is at 133 but still getting error from the advanced search:
>> "Sorry, your query cannot be more than 140 characters long (it is 161
>> characters). "

Reply via email to