Accessing API via IP address

30 views
Skip to first unread message

Jan-Willem

unread,
Jun 25, 2010, 3:48:20 AM6/25/10
to SuperTweet MyAPI Proxy
I am running a very basic Arduino IP stack that has no proper DNS
support. I am trying to post to SuperTweet by its IP address, like
this:

http://66.180.175.246/1/statuses/update.xml

But this results in a 404 error. If I use

http://api.supertweet.net/1/statuses/update.xml

All is well. If I browse to the IP address the web server also asks me
about the context I want to use, so it looks like more than one domain
is handled via this IP.

Is there a way to call the API without using the DNS name? A lot of
"dumb" IP stacks called the Twitter API this way so it would help if
your service could handle it as well.

Thanks,

JW

Mr Blog

unread,
Jun 25, 2010, 10:46:31 AM6/25/10
to SuperTweet MyAPI Proxy
If you're writing the HTTP protocol yourself, just be sure to have a
"Host: api.supertweet.net" header.

Mr Blog

unread,
Jun 25, 2010, 11:08:30 AM6/25/10
to SuperTweet MyAPI Proxy
By glancing around the web for docs, it looks like it's something like
this on your platform:

(e.g. http://jimmyg.org/blog/2009/arduino.html)

byte server[] = { 66, 180, 175, 246 }; // api.supertweet.net

// Start Cthernet client
Client client(server, 80);

if (client.connect()) {
Serial.println("connected");
client.println("POST /1/statuses/update.xml HTTP/1.0");
client.println("Authorization: Basic {secret}");
client.println("Host: api.supertweet.net");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println();
client.println("status=....");

Jan-Willem

unread,
Jun 25, 2010, 11:33:39 AM6/25/10
to SuperTweet MyAPI Proxy
Bingo - that was the little nudge I needed, now I have success:

Botanicalls v2.21

POST /1/statuses/update.xml HTTP/1.1
Host: api.supertweet.net
Authorization: Basic [secret]
Content-Type: application/x-www-form-urlencoded
Content-Length: 28

status=Current Moisture: 0p.
HTTP/1.1 200 OK
Content-Type: text/xml; charset=ISO-8859-1
Date: Fri, 25 Jun 2010 15:29:22 GMT
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Accept-Ranges: bytes
Server: Restlet-Framework/2.0snapshot
Content-Length: 2154

The only thing that fails now it that it chokes if I send a "%" as
part of the status, need to html-ize that probably...

Jan-Willem

unread,
Jun 25, 2010, 11:38:21 AM6/25/10
to SuperTweet MyAPI Proxy
Yep "%25" in stead of "%" and all is well!
Reply all
Reply to author
Forward
0 new messages