I believe "Query string" is everything after the q=, not including the
= of course. So no matter how it is encoded or not, you just count up
the chars, and that should be all you get. It is somewhat limited,
but I do not think entirely designed to do massively complex queries.
I used to try to negate certain twitter users in the #php area, by
taking out things like "freelance" via query string. I did not get
very far before I breached the 140 limit.
Technically speaking, I am not sure why there needs to be a limitation
based on length, it should be based on number of name/value pairs.
Performance wise, the hit is going to come from multiple name value
pairs, and not length.
--
Scott * If you contact me off list replace talklists@ with scott@ *
On Oct 17, 2009, at 9:31 PM, Leon Spencer wrote:
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.
Leon
________________________________
From: Scott Haneda <talkli...@newgeo.com>
To: twitter-development-talk@googlegroups.com
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.
#!/bin/bash
# This script assumes you pre url encode your data.
# Request url
URL="http://search.twitter.com/search.json?q=";
for (( i = 1; i < 200; i++ )); do
# Current position/length
echo "Query Length: "$i;
# Shove on another character
j=$j'A'
# 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 ""
done
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://search.twitter.com/search.json?q=A
http_code: 200
size_request: 163 (Sent bytes)
......
Query Length: 138
http://search.twitter.com/search.json?q=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
http_code: 200
size_request: 300 (Sent bytes)
Query Length: 139
http://search.twitter.com/search.json?q=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
http_code: 200
size_request: 301 (Sent bytes)
Query Length: 140
http://search.twitter.com/search.json?q=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
http_code: 200
size_request: 302 (Sent bytes)
Query Length: 141
http://search.twitter.com/search.json?q=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
http_code: 403
size_request: 303 (Sent bytes)
Query Length: 142
http://search.twitter.com/search.json?q=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
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
http://search.twitter.com/search.atom?geocode=40.757929%2C-73.985506%2C25km
Or
For Since...
http://search.twitter.com/search.atom?q=twitter&since_id=1520639490
On Oct 17, 2:29 pm, leonspencer <spencer_l...@yahoo.com> wrote:
Still waiting for a response here. I tried a query with the Twitter
Advanced Search
tool:http://search.twitter.com/search?q=&ands=Allofthesewords&phrase=Thise...=en&from=leonspencer&to=leonspencer&ref=leonspencer&near=&within=15&units=mi&since=2009-10-07&until=2009-10-18&rpp=15
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:
http://search.twitter.com/search?q=&ands=Allofthesewords&phrase=Thise...=en&from=leonspencer&to=leonspencer&ref=leonspencer&near=&within=15&units=mi&since=2009-10-07&until=2009-10-18&rpp=15
"Sorry, your query cannot be more than 140 characters long (it is
161
characters). "