mirror of
https://github.com/ChronosX88/psyced.git
synced 2024-11-09 20:11:00 +00:00
twitter client now uses oauth and the stream API
This commit is contained in:
parent
c9b3d242a3
commit
5e593a951f
@ -226,7 +226,7 @@ varargs string content(closure cb, int force, int willbehave) {
|
|||||||
if (fetched) {
|
if (fetched) {
|
||||||
if (force) {
|
if (force) {
|
||||||
funcall(cb, fetched, willbehave ? fheaders : copy(fheaders));
|
funcall(cb, fetched, willbehave ? fheaders : copy(fheaders));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
enqueue(ME, ({ cb, willbehave }));
|
enqueue(ME, ({ cb, willbehave }));
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ int buffer_content(string data) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
disconnected(string data) {
|
disconnected(string data) {
|
||||||
P2(("%O got disconnected:\n%O\n", ME, data))
|
P2(("%O got disconnected:\n%O\n", ME, data))
|
||||||
headers["_fetchtime"] = isotime(ctime(time()), 1);
|
headers["_fetchtime"] = isotime(ctime(time()), 1);
|
||||||
@ -42,3 +43,5 @@ disconnected(string data) {
|
|||||||
fetching = 0;
|
fetching = 0;
|
||||||
return 1; // presume this disc was expected
|
return 1; // presume this disc was expected
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -15,7 +15,7 @@
|
|||||||
* - add this to local/config.c:
|
* - add this to local/config.c:
|
||||||
# ifdef USE_TWITTER_STREAM
|
# ifdef USE_TWITTER_STREAM
|
||||||
D(" " NET_PATH "twitter/client\n");
|
D(" " NET_PATH "twitter/client\n");
|
||||||
load_object(NET_PATH "twitter/client")->home_stream();
|
load_object(NET_PATH "twitter/client")->connect();
|
||||||
# endif
|
# endif
|
||||||
*/
|
*/
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
@ -196,7 +196,8 @@ home_timeline(mixed *next) {
|
|||||||
return ua;
|
return ua;
|
||||||
}
|
}
|
||||||
|
|
||||||
home_stream() {
|
connect() {
|
||||||
|
// we currently use a home_stream here
|
||||||
home_timeline(#'user_stream);
|
home_timeline(#'user_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +223,7 @@ user_stream_data(string data, string headers, int http_status, int fetching) {
|
|||||||
switch (http_status) {
|
switch (http_status) {
|
||||||
case 401: // unauthorized
|
case 401: // unauthorized
|
||||||
oauth();
|
oauth();
|
||||||
home_stream();
|
connect();
|
||||||
case 403: // forbidden
|
case 403: // forbidden
|
||||||
case 404: // unknown
|
case 404: // unknown
|
||||||
case 406: // not acceptable
|
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;
|
if (wait > 240) wait = 240;
|
||||||
|
|
||||||
P1(("%O reconnecting in %d seconds.\n", ME, wait))
|
P1(("%O reconnecting in %d seconds.\n", ME, wait))
|
||||||
call_out(#'home_stream, wait); //');
|
call_out(#'connect, wait); //');
|
||||||
}
|
}
|
||||||
|
|
||||||
user_stream() {
|
user_stream() {
|
||||||
P3(("twitter/client:user_stream()\n"))
|
P3(("twitter/client:user_stream()\n"))
|
||||||
if (!authorized) return enqueue(ME, ({ #'user_stream })); //'}));
|
if (!authorized) return enqueue(ME, ({ #'user_stream })); //'}));
|
||||||
friends = 0;
|
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); //');
|
user_ua->content(#'user_stream_data, 1, 1); //');
|
||||||
fetch(user_ua, userstream_url + "/user.json");
|
fetch(user_ua, userstream_url + "/user.json");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user