Anyone know how to send messages to Twitter ?
I've tried the following :
// --------------------------------- //
// Project: Test
// Start: Saturday, July 10, 2010
// IDE Version: 8.036
// ---------------------------------------------------------------------
// Send a HTTP POST Request and return what the webbrowser would display
// ---------------------------------------------------------------------
DEBUG "REsult : "+HttpPost$("","twitter.com","/statuses/update.xml",80,"","Hello World")+"\n"
END
FUNCTION HttpPost$: proxy$, server$, curl$, port%, boundary$, postdata$
LOCAL header$ // the HTTP post header
// Fix proxy urls
IF LEN(proxy$)
curl$ = "http://"+server$+curl$
server$ = proxy$
ENDIF
// end post data
//postdata$ = postdata$ + "--"+boundary$+"--"
LOCAL send$
send$ = "POST "+curl$+" HTTP/1.0\r\n"
INC send$, "Authorization: Basic User:Password\r\n"
INC send$, "status= "+postdata$+"\r\n"
INC send$, "application/x-www-form-urlencoded\r\n"
INC send$, "Content-Length: "+LEN(postdata$) + "\r\n"
INC send$, "\r\n"
INC send$, postdata$
LOCAL sock%, file$
SOCK_INIT()
sock% = SOCK_TCPCONNECT(server$, port%)
IF SOCK_TCPSEND(sock%, send$) > 0
LOCAL chunk$, rv%
WHILE TRUE
chunk$=""
rv% = SOCK_RECV(sock%, chunk$, 1024)
SELECT rv%
CASE -1
DEBUG NETGETLASTERROR$()+"\n"
file$=""
BREAK
CASE -2 // non blocking socket not would block
SLEEP 5
CASE 0
BREAK // ok, reading is done
CASE >0
INC file$, chunk$
ENDSELECT
WEND
// jippieh! We got a response
// split HTTP header and actual file information apart
LOCAL pos%
pos = INSTR(file$, "\r\n\r\n")
IF pos>=0
header$ = MID$(file$, 0, pos%)
file$ = MID$(file$, pos%+4)
ELSE
header$=""
ENDIF
ELSE
DEBUG "Failed\n"
ENDIF
SOCK_CLOSE(sock%)
RETURN file$
ENDFUNCTION
(using my User and Password), but all I get back is :
Quote<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Request header field is missing ':' separator.<br />
<pre>
status=Hello World</pre>
</p>
</body></html>
you must send the postdata with the AddPostData function I wrote. It's like:
variablename : value of variable\r\n
or so...
Just wish I knew what variables to send...
I did get something correct back - unfortunately a new authorisation system is now used...
google, there's obviously lots of tutorials I guess.
Unfortunately only for web-based languages...
Perhaps there would be a way to do a http post command to call some PHP that will in turn make the post to Twitter.