twitter client now uses oauth and the stream API

This commit is contained in:
psyc://psyced.org/~lynX 2011-08-24 11:21:22 +02:00
parent c9b3d242a3
commit 5e593a951f
3 changed files with 10 additions and 6 deletions

View File

@ -226,7 +226,7 @@ varargs string content(closure cb, int force, int willbehave) {
if (fetched) {
if (force) {
funcall(cb, fetched, willbehave ? fheaders : copy(fheaders));
}
}
} else {
enqueue(ME, ({ cb, willbehave }));
}

View File

@ -14,6 +14,7 @@ int buffer_content(string data) {
return 1;
}
#if 0
disconnected(string data) {
P2(("%O got disconnected:\n%O\n", ME, data))
headers["_fetchtime"] = isotime(ctime(time()), 1);
@ -42,3 +43,5 @@ disconnected(string data) {
fetching = 0;
return 1; // presume this disc was expected
}
#endif

View File

@ -15,7 +15,7 @@
* - add this to local/config.c:
# ifdef USE_TWITTER_STREAM
D(" " NET_PATH "twitter/client\n");
load_object(NET_PATH "twitter/client")->home_stream();
load_object(NET_PATH "twitter/client")->connect();
# endif
*/
#include <net.h>
@ -196,7 +196,8 @@ home_timeline(mixed *next) {
return ua;
}
home_stream() {
connect() {
// we currently use a home_stream here
home_timeline(#'user_stream);
}
@ -222,7 +223,7 @@ user_stream_data(string data, string headers, int http_status, int fetching) {
switch (http_status) {
case 401: // unauthorized
oauth();
home_stream();
connect();
case 403: // forbidden
case 404: // unknown
case 406: // not acceptable
@ -241,14 +242,14 @@ user_stream_data(string data, string headers, int http_status, int fetching) {
if (wait > 240) wait = 240;
P1(("%O reconnecting in %d seconds.\n", ME, wait))
call_out(#'home_stream, wait); //');
call_out(#'connect, wait); //');
}
user_stream() {
P3(("twitter/client:user_stream()\n"))
if (!authorized) return enqueue(ME, ({ #'user_stream })); //'}));
friends = 0;
object user_ua = clone_object(NET_PATH "http/fetch_stream");
object user_ua = clone_object(NET_PATH "http/stream");
user_ua->content(#'user_stream_data, 1, 1); //');
fetch(user_ua, userstream_url + "/user.json");
}