if (!is_null($location) && strlen($location) > 255) {
- // XXX: Twitter just truncates and runs with it.
+ // XXX: But Twitter just truncates and runs with it. -- Zach
header('HTTP/1.1 406 Not Acceptable');
print "That's too long. Max notice size is 255 chars.\n";
exit();
if (!$other) {
$this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
exit();
- return;
}
$user = $apidata['user'];
if ($user->isSubscribed($other)) {
$this->client_error("Could not follow user: $other->nickname is already on your list.", 403, $apidata['content-type']);
exit();
- return;
}
$sub = new Subscription();
if (!$result) {
$this->client_error("Could not follow user: $other->nickname.", 400, $apidata['content-type']);
exit();
- return;
}
$sub->query('COMMIT');
$type = $apidata['content-type'];
$this->init_document($type);
- $this->show_profile($other);
+ $this->show_profile($other, $type);
$this->end_document($type);
exit();
}
}
$type = $apidata['content-type'];
- $this->init_document($type);
- $this->show_profile($other);
+ $this->init_document($type);
+ $this->show_profile($other, $type);
$this->end_document($type);
exit();
}
$user_a = $this->get_profile($user_a_id);
$user_b = $this->get_profile($user_b_id);
- if($user_a) { print "got user a profile";}
- if($user_b) { print "got user b profile";}
-
-
if (!$user_a || !$user_b) {
$this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
exit();
switch ($apidata['content-type']) {
case 'xml':
- common_start_xml();
+ $this->init_document('xml');
common_element('friends', NULL, $result);
- common_end_xml();
+ $this->end_document('xml');
break;
case 'json':
+ $this->init_document('json');
print json_encode($result);
+ $this->end_document('json');
break;
default:
- print $result;
+ print $result; // Really? --Zach
break;
}
function test($args, $apidata) {
global $xw;
if ($apidata['content-type'] == 'xml') {
- header('Content-Type: application/xml; charset=utf-8');
+ $this->init_document('xml');
common_start_xml();
common_element('ok', NULL, 'true');
common_end_xml();
+ $this->end_document('xml');
} elseif ($apidata['content-type'] == 'json') {
- header('Content-Type: application/json; charset=utf-8');
+ $this->init_document('json');
print '"ok"';
+ $this->end_document('json');
} else {
common_user_error("API method not found!", $code=404);
}
function show_xml_timeline($notice) {
- header('Content-Type: application/xml; charset=utf-8');
- common_start_xml();
+ $this->init_document('xml');
common_element_start('statuses', array('type' => 'array'));
if (is_array($notice)) {
}
common_element_end('statuses');
- common_end_xml();
+ $this->end_document('xml');
}
function show_rss_timeline($notice, $title, $id, $link, $subtitle) {
- header("Content-Type: application/rss+xml; charset=utf-8");
-
- $this->init_twitter_rss();
+ $this->init_document('rss');
common_element_start('channel');
common_element('title', NULL, $title);
}
common_element_end('channel');
- $this->end_twitter_rss();
+ $this->end_twitter_rss();
}
function show_atom_timeline($notice, $title, $id, $link, $subtitle=NULL) {
- header('Content-Type: application/atom+xml; charset=utf-8');
-
- $this->init_twitter_atom();
+ $this->init_document('atom');
common_element('title', NULL, $title);
common_element('id', NULL, $id);
}
}
- $this->end_twitter_atom();
+ $this->end_document('atom');
+
}
function show_json_timeline($notice) {
- header('Content-Type: application/json; charset=utf-8');
+ $this->init_document('json');
$statuses = array();
}
$this->show_twitter_json_statuses($statuses);
+
+ $this->end_document('json');
}
/*
ID. Ex: http://server/api/statuses/replies.xml?since_id=12345
*/
function replies($args, $apidata) {
+
parent::handle($args);
$since = $this->arg('since');
return $entry;
}
- function show_twitter_xml_status($twitter_status) {
+ function show_twitter_xml_status($twitter_status) {
common_element_start('status');
common_element('created_at', NULL, $twitter_status['created_at']);
common_element('id', NULL, $twitter_status['id']);
}
function show_single_xml_status($notice) {
- header('Content-Type: application/xml; charset=utf-8');
- common_start_xml();
+ $this->init_document('xml');
$twitter_status = $this->twitter_status_array($notice);
$this->show_twitter_xml_status($twitter_status);
- common_end_xml();
+ $this->end_document('xml');
exit();
}
function show_single_json_status($notice) {
- header('Content-Type: application/json; charset=utf-8');
+ $this->init_document('json');
$status = $this->twitter_status_array($notice);
$this->show_twitter_json_statuses($status);
+ $this->end_document('json');
exit();
}
$this->client_error(_('Unsupported type'));
break;
}
+
+ return;
}
function end_document($type='xml') {
$this->client_error(_('Unsupported type'));
break;
}
+ return;
}
function client_error($msg, $code = 400, $content_type = 'json') {
header('HTTP/1.1 '.$code.' '.$status_string);
if ($content_type == 'xml') {
- common_start_xml();
+ $this->init_document('xml');
common_element_start('hash');
common_element('error', NULL, $msg);
common_element('request', NULL, $_SERVER['REQUEST_URI']);
common_element_end('hash');
- common_end_xml();
+ $this->end_document('xml');
} else {
+ $this->init_document('json');
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
- print(json_encode($error_array));
+ print(json_encode($error_array));
+ $this->end_document('json');
}
exit();
common_element_end('feed');
}
- function show_profile($profile, $content_type='xml', $notice=NULL) {
+ function show_profile($profile, $content_type='xml', $notice=NULL) {
$profile_array = $this->twitter_user_array($profile, true);
switch ($content_type) {
case 'xml':
$this->client_error(_('not a supported data format'));
return;
}
+ return;
}
}
\ No newline at end of file