CamelCase all function names in the API code
This commit is contained in:
parent
b08d16ef2b
commit
061af8fa06
@ -73,7 +73,7 @@ class ApiAccountRateLimitStatusAction extends ApiBareAuthAction
|
|||||||
$reset = new DateTime();
|
$reset = new DateTime();
|
||||||
$reset->modify('+1 hour');
|
$reset->modify('+1 hour');
|
||||||
|
|
||||||
$this->init_document($this->format);
|
$this->initDocument($this->format);
|
||||||
|
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
@ -101,7 +101,7 @@ class ApiAccountRateLimitStatusAction extends ApiBareAuthAction
|
|||||||
print json_encode($out);
|
print json_encode($out);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_document($this->format);
|
$this->endDocument($this->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,9 @@ class ApiBlockCreateAction extends ApiAuthAction
|
|||||||
if ($this->user->hasBlocked($this->other)
|
if ($this->user->hasBlocked($this->other)
|
||||||
|| $this->user->block($this->other)
|
|| $this->user->block($this->other)
|
||||||
) {
|
) {
|
||||||
$this->init_document($this->format);
|
$this->initDocument($this->format);
|
||||||
$this->show_profile($this->other, $this->format);
|
$this->showProfile($this->other, $this->format);
|
||||||
$this->end_document($this->format);
|
$this->endDocument($this->format);
|
||||||
} else {
|
} else {
|
||||||
$this->serverError(_('Block user failed.'), 500, $this->format);
|
$this->serverError(_('Block user failed.'), 500, $this->format);
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,9 @@ class ApiBlockDestroyAction extends ApiAuthAction
|
|||||||
if (!$this->user->hasBlocked($this->other)
|
if (!$this->user->hasBlocked($this->other)
|
||||||
|| $this->user->unblock($this->other)
|
|| $this->user->unblock($this->other)
|
||||||
) {
|
) {
|
||||||
$this->init_document($this->format);
|
$this->initDocument($this->format);
|
||||||
$this->show_profile($this->other, $this->format);
|
$this->showProfile($this->other, $this->format);
|
||||||
$this->end_document($this->format);
|
$this->endDocument($this->format);
|
||||||
} else {
|
} else {
|
||||||
$this->serverError(_('Unblock user failed.'));
|
$this->serverError(_('Unblock user failed.'));
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
|
|
||||||
function showXmlDirectMessages()
|
function showXmlDirectMessages()
|
||||||
{
|
{
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('direct-messages', array('type' => 'array'));
|
$this->elementStart('direct-messages', array('type' => 'array'));
|
||||||
|
|
||||||
foreach ($this->messages as $m) {
|
foreach ($this->messages as $m) {
|
||||||
@ -239,7 +239,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->elementEnd('direct-messages');
|
$this->elementEnd('direct-messages');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,7 +250,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
|
|
||||||
function showJsonDirectMessages()
|
function showJsonDirectMessages()
|
||||||
{
|
{
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
|
|
||||||
$dmsgs = array();
|
$dmsgs = array();
|
||||||
|
|
||||||
@ -259,8 +259,8 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
array_push($dmsgs, $dm_array);
|
array_push($dmsgs, $dm_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_json_objects($dmsgs);
|
$this->showJsonObjects($dmsgs);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -271,7 +271,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
|
|
||||||
function showRssDirectMessages()
|
function showRssDirectMessages()
|
||||||
{
|
{
|
||||||
$this->init_document('rss');
|
$this->initDocument('rss');
|
||||||
|
|
||||||
$this->element('title', null, $this->title);
|
$this->element('title', null, $this->title);
|
||||||
|
|
||||||
@ -292,10 +292,10 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
|
|
||||||
foreach ($this->messages as $m) {
|
foreach ($this->messages as $m) {
|
||||||
$entry = $this->rssDirectMessageArray($m);
|
$entry = $this->rssDirectMessageArray($m);
|
||||||
$this->show_twitter_rss_item($entry);
|
$this->showTwitterRssItem($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_twitter_rss();
|
$this->endTwitterRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,7 +306,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
|
|
||||||
function showAtomDirectMessages()
|
function showAtomDirectMessages()
|
||||||
{
|
{
|
||||||
$this->init_document('atom');
|
$this->initDocument('atom');
|
||||||
|
|
||||||
$this->element('title', null, $this->title);
|
$this->element('title', null, $this->title);
|
||||||
$this->element('id', null, $this->id);
|
$this->element('id', null, $this->id);
|
||||||
@ -334,7 +334,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
|||||||
$this->showTwitterAtomEntry($entry);
|
$this->showTwitterAtomEntry($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_document('atom');
|
$this->endDocument('atom');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +135,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
|
|||||||
$this->user->blowFavesCache();
|
$this->user->blowFavesCache();
|
||||||
|
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->show_single_xml_status($this->notice);
|
$this->showSingleXmlStatus($this->notice);
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->show_single_json_status($this->notice);
|
$this->show_single_json_status($this->notice);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ class ApiFavoriteDestroyAction extends ApiAuthAction
|
|||||||
$this->user->blowFavesCache();
|
$this->user->blowFavesCache();
|
||||||
|
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->show_single_xml_status($this->notice);
|
$this->showSingleXmlStatus($this->notice);
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->show_single_json_status($this->notice);
|
$this->show_single_json_status($this->notice);
|
||||||
}
|
}
|
||||||
|
@ -126,9 +126,9 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->init_document($this->format);
|
$this->initDocument($this->format);
|
||||||
$this->show_profile($this->other, $this->format);
|
$this->showProfile($this->other, $this->format);
|
||||||
$this->end_document($this->format);
|
$this->endDocument($this->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -128,9 +128,9 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->init_document($this->format);
|
$this->initDocument($this->format);
|
||||||
$this->show_profile($this->other, $this->format);
|
$this->showProfile($this->other, $this->format);
|
||||||
$this->end_document($this->format);
|
$this->endDocument($this->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,14 +107,14 @@ class ApiFriendshipsExistsAction extends ApiAction
|
|||||||
|
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->element('friends', null, $result);
|
$this->element('friends', null, $result);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
print json_encode($result);
|
print json_encode($result);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -143,18 +143,18 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->twitter_relationship_array($this->source, $this->target);
|
$result = $this->twitterRelationshipArray($this->source, $this->target);
|
||||||
|
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->show_twitter_xml_relationship($result[relationship]);
|
$this->showTwitterXmlRelationship($result[relationship]);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
print json_encode($result);
|
print json_encode($result);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -95,14 +95,14 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->element('is_member', null, $is_member);
|
$this->element('is_member', null, $is_member);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$this->show_json_objects(array('is_member' => $is_member));
|
$this->showJsonObjects(array('is_member' => $is_member));
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -143,7 +143,7 @@ class ApiGroupJoinAction extends ApiAuthAction
|
|||||||
$this->show_single_xml_group($this->group);
|
$this->show_single_xml_group($this->group);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_single_json_group($this->group);
|
$this->showSingleJsonGroup($this->group);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -129,7 +129,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
|
|||||||
$this->show_single_xml_group($this->group);
|
$this->show_single_xml_group($this->group);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_single_json_group($this->group);
|
$this->showSingleJsonGroup($this->group);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -101,15 +101,15 @@ class ApiGroupListAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_groups($this->groups);
|
$this->showXmlGroups($this->groups);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_groups($this->groups, $title, $link, $subtitle);
|
$this->showRssGroups($this->groups, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() . 'api/statusnet/groups/list/' .
|
$selfuri = common_root_url() . 'api/statusnet/groups/list/' .
|
||||||
$this->user->id . '.atom';
|
$this->user->id . '.atom';
|
||||||
$this->show_atom_groups(
|
$this->showAtomGroups(
|
||||||
$this->groups,
|
$this->groups,
|
||||||
$title,
|
$title,
|
||||||
$id,
|
$id,
|
||||||
@ -119,7 +119,7 @@ class ApiGroupListAction extends ApiBareAuthAction
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_groups($this->groups);
|
$this->showJsonGroups($this->groups);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -89,15 +89,15 @@ class ApiGroupListAllAction extends ApiAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_groups($this->groups);
|
$this->showXmlGroups($this->groups);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_groups($this->groups, $title, $link, $subtitle);
|
$this->showRssGroups($this->groups, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statusnet/groups/list_all.atom';
|
'api/statusnet/groups/list_all.atom';
|
||||||
$this->show_atom_groups(
|
$this->showAtomGroups(
|
||||||
$this->groups,
|
$this->groups,
|
||||||
$title,
|
$title,
|
||||||
$id,
|
$id,
|
||||||
@ -107,7 +107,7 @@ class ApiGroupListAllAction extends ApiAction
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_groups($this->groups);
|
$this->showJsonGroups($this->groups);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -85,10 +85,10 @@ class ApiGroupMembershipAction extends ApiAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_twitter_xml_users($this->profiles);
|
$this->showTwitterXmlUsers($this->profiles);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_users($this->profiles);
|
$this->showJsonUsers($this->profiles);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -93,7 +93,7 @@ class ApiGroupShowAction extends ApiAction
|
|||||||
$this->show_single_xml_group($this->group);
|
$this->show_single_xml_group($this->group);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_single_json_group($this->group);
|
$this->showSingleJsonGroup($this->group);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), 404, $this->format);
|
$this->clientError(_('API method not found!'), 404, $this->format);
|
||||||
|
@ -74,13 +74,13 @@ class ApiHelpTestAction extends ApiAction
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->element('ok', null, 'true');
|
$this->element('ok', null, 'true');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
print '"ok"';
|
print '"ok"';
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
} else {
|
} else {
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
_('API method not found!'),
|
_('API method not found!'),
|
||||||
|
@ -112,7 +112,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction
|
|||||||
$this->notice->delete();
|
$this->notice->delete();
|
||||||
|
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->show_single_xml_status($this->notice);
|
$this->showSingleXmlStatus($this->notice);
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->show_single_json_status($this->notice);
|
$this->show_single_json_status($this->notice);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction
|
|||||||
{
|
{
|
||||||
if (!empty($this->notice)) {
|
if (!empty($this->notice)) {
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->show_single_xml_status($this->notice);
|
$this->showSingleXmlStatus($this->notice);
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->show_single_json_status($this->notice);
|
$this->show_single_json_status($this->notice);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ class ApiStatusesShowAction extends ApiAction
|
|||||||
{
|
{
|
||||||
if (!empty($this->notice)) {
|
if (!empty($this->notice)) {
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->show_single_xml_status($this->notice);
|
$this->showSingleXmlStatus($this->notice);
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->show_single_json_status($this->notice);
|
$this->show_single_json_status($this->notice);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
{
|
{
|
||||||
if (!empty($this->notice)) {
|
if (!empty($this->notice)) {
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->show_single_xml_status($this->notice);
|
$this->showSingleXmlStatus($this->notice);
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->show_single_json_status($this->notice);
|
$this->show_single_json_status($this->notice);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class ApiStatusnetConfigAction extends ApiAction
|
|||||||
|
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('config');
|
$this->elementStart('config');
|
||||||
|
|
||||||
// XXX: check that all sections and settings are legal XML elements
|
// XXX: check that all sections and settings are legal XML elements
|
||||||
@ -111,7 +111,7 @@ class ApiStatusnetConfigAction extends ApiAction
|
|||||||
$this->elementEnd($section);
|
$this->elementEnd($section);
|
||||||
}
|
}
|
||||||
$this->elementEnd('config');
|
$this->elementEnd('config');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$result = array();
|
$result = array();
|
||||||
@ -122,9 +122,9 @@ class ApiStatusnetConfigAction extends ApiAction
|
|||||||
= common_config($section, $setting);
|
= common_config($section, $setting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$this->show_json_objects($result);
|
$this->showJsonObjects($result);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -77,14 +77,14 @@ class ApiStatusnetVersionAction extends ApiAction
|
|||||||
|
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->element('version', null, STATUSNET_VERSION);
|
$this->element('version', null, STATUSNET_VERSION);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
print '"'.STATUSNET_VERSION.'"';
|
print '"'.STATUSNET_VERSION.'"';
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -108,7 +108,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->init_document($this->format);
|
$this->initDocument($this->format);
|
||||||
|
|
||||||
if (isset($this->ids_only)) {
|
if (isset($this->ids_only)) {
|
||||||
$this->showIds();
|
$this->showIds();
|
||||||
@ -116,7 +116,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
|
|||||||
$this->showProfiles(isset($this->lite) ? false : true);
|
$this->showProfiles(isset($this->lite) ? false : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_document($this->format);
|
$this->endDocument($this->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,7 +204,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
|
|||||||
case 'xml':
|
case 'xml':
|
||||||
$this->elementStart('users', array('type' => 'array'));
|
$this->elementStart('users', array('type' => 'array'));
|
||||||
foreach ($this->profiles as $profile) {
|
foreach ($this->profiles as $profile) {
|
||||||
$this->show_profile(
|
$this->showProfile(
|
||||||
$profile,
|
$profile,
|
||||||
$this->format,
|
$this->format,
|
||||||
null,
|
null,
|
||||||
@ -216,7 +216,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
|
|||||||
case 'json':
|
case 'json':
|
||||||
$arrays = array();
|
$arrays = array();
|
||||||
foreach ($this->profiles as $profile) {
|
foreach ($this->profiles as $profile) {
|
||||||
$arrays[] = $this->twitter_user_array(
|
$arrays[] = $this->twitterUserArray(
|
||||||
$profile,
|
$profile,
|
||||||
$include_statuses
|
$include_statuses
|
||||||
);
|
);
|
||||||
|
@ -121,21 +121,21 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link, $subtitle,
|
$this->notices, $title, $id, $link, $subtitle,
|
||||||
null, $selfuri
|
null, $selfuri
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
@ -112,10 +112,10 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
|
|
||||||
@ -130,13 +130,13 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
|||||||
'api/statuses/friends_timeline.atom';
|
'api/statuses/friends_timeline.atom';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link,
|
$this->notices, $title, $id, $link,
|
||||||
$subtitle, null, $selfuri
|
$subtitle, null, $selfuri
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
@ -108,16 +108,16 @@ class ApiTimelineGroupAction extends ApiAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statusnet/groups/timeline/' .
|
'api/statusnet/groups/timeline/' .
|
||||||
$this->group->nickname . '.atom';
|
$this->group->nickname . '.atom';
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices,
|
$this->notices,
|
||||||
$title,
|
$title,
|
||||||
$id,
|
$id,
|
||||||
@ -128,7 +128,7 @@ class ApiTimelineGroupAction extends ApiAction
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(
|
$this->clientError(
|
||||||
|
@ -118,21 +118,21 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link, $subtitle,
|
$this->notices, $title, $id, $link, $subtitle,
|
||||||
null, $selfuri
|
null, $selfuri
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
@ -99,20 +99,20 @@ class ApiTimelinePublicAction extends ApiAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
|
$selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link,
|
$this->notices, $title, $id, $link,
|
||||||
$subtitle, null, $selfuri
|
$subtitle, null, $selfuri
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
@ -107,16 +107,16 @@ class ApiTimelineTagAction extends ApiAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statusnet/tags/timeline/' .
|
'api/statusnet/tags/timeline/' .
|
||||||
$this->tag . '.atom';
|
$this->tag . '.atom';
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices,
|
$this->notices,
|
||||||
$title,
|
$title,
|
||||||
$id,
|
$id,
|
||||||
@ -127,7 +127,7 @@ class ApiTimelineTagAction extends ApiAction
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
@ -123,10 +123,10 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_xml_timeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->show_rss_timeline(
|
$this->showRssTimeline(
|
||||||
$this->notices, $title, $link,
|
$this->notices, $title, $link,
|
||||||
$subtitle, $suplink
|
$subtitle, $suplink
|
||||||
);
|
);
|
||||||
@ -140,13 +140,13 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statuses/user_timeline.atom';
|
'api/statuses/user_timeline.atom';
|
||||||
}
|
}
|
||||||
$this->show_atom_timeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link,
|
$this->notices, $title, $id, $link,
|
||||||
$subtitle, $suplink, $selfuri
|
$subtitle, $suplink, $selfuri
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($this->notices);
|
$this->showJsonTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
@ -105,16 +105,16 @@ class ApiUserShowAction extends ApiAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$twitter_user = $this->twitter_user_array($this->user->getProfile(), true);
|
$twitter_user = $this->twitterUserArray($this->user->getProfile(), true);
|
||||||
|
|
||||||
if ($this->format == 'xml') {
|
if ($this->format == 'xml') {
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->show_twitter_xml_user($twitter_user);
|
$this->showTwitterXmlUser($twitter_user);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
} elseif ($this->format == 'json') {
|
} elseif ($this->format == 'json') {
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$this->show_json_objects($twitter_user);
|
$this->showJsonObjects($twitter_user);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ class TwitapisearchatomAction extends ApiAction
|
|||||||
// TODO: Here is where we'd put in a link to an atom feed for threads
|
// TODO: Here is where we'd put in a link to an atom feed for threads
|
||||||
|
|
||||||
$this->element("twitter:source", null,
|
$this->element("twitter:source", null,
|
||||||
htmlentities($this->source_link($notice->source)));
|
htmlentities($this->sourceLink($notice->source)));
|
||||||
|
|
||||||
$this->elementStart('author');
|
$this->elementStart('author');
|
||||||
|
|
||||||
|
@ -134,9 +134,9 @@ class TwitapisearchjsonAction extends ApiAction
|
|||||||
|
|
||||||
$results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page);
|
$results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page);
|
||||||
|
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$results->show();
|
$results->show();
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
295
lib/api.php
295
lib/api.php
@ -106,7 +106,7 @@ class ApiAction extends Action
|
|||||||
return parent::element($tag, $attrs, $content);
|
return parent::element($tag, $attrs, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_user_array($profile, $get_notice=false)
|
function twitterUserArray($profile, $get_notice=false)
|
||||||
{
|
{
|
||||||
$twitter_user = array();
|
$twitter_user = array();
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
$twitter_user['friends_count'] = $profile->subscriptionCount();
|
$twitter_user['friends_count'] = $profile->subscriptionCount();
|
||||||
|
|
||||||
$twitter_user['created_at'] = $this->date_twitter($profile->created);
|
$twitter_user['created_at'] = $this->dateTwitter($profile->created);
|
||||||
|
|
||||||
$twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
|
$twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
|
||||||
|
|
||||||
@ -179,24 +179,24 @@ class ApiAction extends Action
|
|||||||
$notice = $profile->getCurrentNotice();
|
$notice = $profile->getCurrentNotice();
|
||||||
if ($notice) {
|
if ($notice) {
|
||||||
# don't get user!
|
# don't get user!
|
||||||
$twitter_user['status'] = $this->twitter_status_array($notice, false);
|
$twitter_user['status'] = $this->twitterStatusArray($notice, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $twitter_user;
|
return $twitter_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_status_array($notice, $include_user=true)
|
function twitterStatusArray($notice, $include_user=true)
|
||||||
{
|
{
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
|
|
||||||
$twitter_status = array();
|
$twitter_status = array();
|
||||||
$twitter_status['text'] = $notice->content;
|
$twitter_status['text'] = $notice->content;
|
||||||
$twitter_status['truncated'] = false; # Not possible on StatusNet
|
$twitter_status['truncated'] = false; # Not possible on StatusNet
|
||||||
$twitter_status['created_at'] = $this->date_twitter($notice->created);
|
$twitter_status['created_at'] = $this->dateTwitter($notice->created);
|
||||||
$twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
|
$twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
|
||||||
intval($notice->reply_to) : null;
|
intval($notice->reply_to) : null;
|
||||||
$twitter_status['source'] = $this->source_link($notice->source);
|
$twitter_status['source'] = $this->sourceLink($notice->source);
|
||||||
$twitter_status['id'] = intval($notice->id);
|
$twitter_status['id'] = intval($notice->id);
|
||||||
|
|
||||||
$replier_profile = null;
|
$replier_profile = null;
|
||||||
@ -239,14 +239,14 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
if ($include_user) {
|
if ($include_user) {
|
||||||
# Don't get notice (recursive!)
|
# Don't get notice (recursive!)
|
||||||
$twitter_user = $this->twitter_user_array($profile, false);
|
$twitter_user = $this->twitterUserArray($profile, false);
|
||||||
$twitter_status['user'] = $twitter_user;
|
$twitter_status['user'] = $twitter_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $twitter_status;
|
return $twitter_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_group_array($group)
|
function twitterGroupArray($group)
|
||||||
{
|
{
|
||||||
$twitter_group=array();
|
$twitter_group=array();
|
||||||
$twitter_group['id']=$group->id;
|
$twitter_group['id']=$group->id;
|
||||||
@ -261,12 +261,12 @@ class ApiAction extends Action
|
|||||||
$twitter_group['homepage']=$group->homepage;
|
$twitter_group['homepage']=$group->homepage;
|
||||||
$twitter_group['description']=$group->description;
|
$twitter_group['description']=$group->description;
|
||||||
$twitter_group['location']=$group->location;
|
$twitter_group['location']=$group->location;
|
||||||
$twitter_group['created']=$this->date_twitter($group->created);
|
$twitter_group['created']=$this->dateTwitter($group->created);
|
||||||
$twitter_group['modified']=$this->date_twitter($group->modified);
|
$twitter_group['modified']=$this->dateTwitter($group->modified);
|
||||||
return $twitter_group;
|
return $twitter_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_rss_group_array($group)
|
function twitterRssGroupArray($group)
|
||||||
{
|
{
|
||||||
$entry = array();
|
$entry = array();
|
||||||
$entry['content']=$group->description;
|
$entry['content']=$group->description;
|
||||||
@ -284,7 +284,7 @@ class ApiAction extends Action
|
|||||||
return $entry;
|
return $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_rss_entry_array($notice)
|
function twitterRssEntryArray($notice)
|
||||||
{
|
{
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
$entry = array();
|
$entry = array();
|
||||||
@ -341,19 +341,19 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function twitter_relationship_array($source, $target)
|
function twitterRelationshipArray($source, $target)
|
||||||
{
|
{
|
||||||
$relationship = array();
|
$relationship = array();
|
||||||
|
|
||||||
$relationship['source'] =
|
$relationship['source'] =
|
||||||
$this->relationship_details_array($source, $target);
|
$this->relationshipDetailsArray($source, $target);
|
||||||
$relationship['target'] =
|
$relationship['target'] =
|
||||||
$this->relationship_details_array($target, $source);
|
$this->relationshipDetailsArray($target, $source);
|
||||||
|
|
||||||
return array('relationship' => $relationship);
|
return array('relationship' => $relationship);
|
||||||
}
|
}
|
||||||
|
|
||||||
function relationship_details_array($source, $target)
|
function relationshipDetailsArray($source, $target)
|
||||||
{
|
{
|
||||||
$details = array();
|
$details = array();
|
||||||
|
|
||||||
@ -380,14 +380,14 @@ class ApiAction extends Action
|
|||||||
return $details;
|
return $details;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_xml_relationship($relationship)
|
function showTwitterXmlRelationship($relationship)
|
||||||
{
|
{
|
||||||
$this->elementStart('relationship');
|
$this->elementStart('relationship');
|
||||||
|
|
||||||
foreach($relationship as $element => $value) {
|
foreach($relationship as $element => $value) {
|
||||||
if ($element == 'source' || $element == 'target') {
|
if ($element == 'source' || $element == 'target') {
|
||||||
$this->elementStart($element);
|
$this->elementStart($element);
|
||||||
$this->show_xml_relationship_details($value);
|
$this->showXmlRelationshipDetails($value);
|
||||||
$this->elementEnd($element);
|
$this->elementEnd($element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,26 +395,26 @@ class ApiAction extends Action
|
|||||||
$this->elementEnd('relationship');
|
$this->elementEnd('relationship');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_xml_relationship_details($details)
|
function showXmlRelationshipDetails($details)
|
||||||
{
|
{
|
||||||
foreach($details as $element => $value) {
|
foreach($details as $element => $value) {
|
||||||
$this->element($element, null, $value);
|
$this->element($element, null, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_xml_status($twitter_status)
|
function showTwitterXmlStatus($twitter_status)
|
||||||
{
|
{
|
||||||
$this->elementStart('status');
|
$this->elementStart('status');
|
||||||
foreach($twitter_status as $element => $value) {
|
foreach($twitter_status as $element => $value) {
|
||||||
switch ($element) {
|
switch ($element) {
|
||||||
case 'user':
|
case 'user':
|
||||||
$this->show_twitter_xml_user($twitter_status['user']);
|
$this->showTwitterXmlUser($twitter_status['user']);
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
$this->element($element, null, common_xml_safe_str($value));
|
$this->element($element, null, common_xml_safe_str($value));
|
||||||
break;
|
break;
|
||||||
case 'attachments':
|
case 'attachments':
|
||||||
$this->show_xml_attachments($twitter_status['attachments']);
|
$this->showXmlAttachments($twitter_status['attachments']);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->element($element, null, $value);
|
$this->element($element, null, $value);
|
||||||
@ -423,7 +423,7 @@ class ApiAction extends Action
|
|||||||
$this->elementEnd('status');
|
$this->elementEnd('status');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_xml_group($twitter_group)
|
function showTwitterXmlGroup($twitter_group)
|
||||||
{
|
{
|
||||||
$this->elementStart('group');
|
$this->elementStart('group');
|
||||||
foreach($twitter_group as $element => $value) {
|
foreach($twitter_group as $element => $value) {
|
||||||
@ -432,12 +432,12 @@ class ApiAction extends Action
|
|||||||
$this->elementEnd('group');
|
$this->elementEnd('group');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_xml_user($twitter_user, $role='user')
|
function showTwitterXmlUser($twitter_user, $role='user')
|
||||||
{
|
{
|
||||||
$this->elementStart($role);
|
$this->elementStart($role);
|
||||||
foreach($twitter_user as $element => $value) {
|
foreach($twitter_user as $element => $value) {
|
||||||
if ($element == 'status') {
|
if ($element == 'status') {
|
||||||
$this->show_twitter_xml_status($twitter_user['status']);
|
$this->showTwitterXmlStatus($twitter_user['status']);
|
||||||
} else {
|
} else {
|
||||||
$this->element($element, null, $value);
|
$this->element($element, null, $value);
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ class ApiAction extends Action
|
|||||||
$this->elementEnd($role);
|
$this->elementEnd($role);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_xml_attachments($attachments) {
|
function showXmlAttachments($attachments) {
|
||||||
if (!empty($attachments)) {
|
if (!empty($attachments)) {
|
||||||
$this->elementStart('attachments', array('type' => 'array'));
|
$this->elementStart('attachments', array('type' => 'array'));
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
@ -459,7 +459,7 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_rss_item($entry)
|
function showTwitterRssItem($entry)
|
||||||
{
|
{
|
||||||
$this->elementStart('item');
|
$this->elementStart('item');
|
||||||
$this->element('title', null, $entry['title']);
|
$this->element('title', null, $entry['title']);
|
||||||
@ -483,59 +483,59 @@ class ApiAction extends Action
|
|||||||
$this->elementEnd('item');
|
$this->elementEnd('item');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_json_objects($objects)
|
function showJsonObjects($objects)
|
||||||
{
|
{
|
||||||
print(json_encode($objects));
|
print(json_encode($objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_single_xml_status($notice)
|
function showSingleXmlStatus($notice)
|
||||||
{
|
{
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$twitter_status = $this->twitter_status_array($notice);
|
$twitter_status = $this->twitterStatusArray($notice);
|
||||||
$this->show_twitter_xml_status($twitter_status);
|
$this->showTwitterXmlStatus($twitter_status);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_single_json_status($notice)
|
function show_single_json_status($notice)
|
||||||
{
|
{
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$status = $this->twitter_status_array($notice);
|
$status = $this->twitterStatusArray($notice);
|
||||||
$this->show_json_objects($status);
|
$this->showJsonObjects($status);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function show_xml_timeline($notice)
|
function showXmlTimeline($notice)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('statuses', array('type' => 'array'));
|
$this->elementStart('statuses', array('type' => 'array'));
|
||||||
|
|
||||||
if (is_array($notice)) {
|
if (is_array($notice)) {
|
||||||
foreach ($notice as $n) {
|
foreach ($notice as $n) {
|
||||||
$twitter_status = $this->twitter_status_array($n);
|
$twitter_status = $this->twitterStatusArray($n);
|
||||||
$this->show_twitter_xml_status($twitter_status);
|
$this->showTwitterXmlStatus($twitter_status);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
$twitter_status = $this->twitter_status_array($notice);
|
$twitter_status = $this->twitterStatusArray($notice);
|
||||||
$this->show_twitter_xml_status($twitter_status);
|
$this->showTwitterXmlStatus($twitter_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementEnd('statuses');
|
$this->elementEnd('statuses');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=null)
|
function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('rss');
|
$this->initDocument('rss');
|
||||||
|
|
||||||
$this->element('title', null, $title);
|
$this->element('title', null, $title);
|
||||||
$this->element('link', null, $link);
|
$this->element('link', null, $link);
|
||||||
if (!is_null($suplink)) {
|
if (!is_null($suplink)) {
|
||||||
# For FriendFeed's SUP protocol
|
// For FriendFeed's SUP protocol
|
||||||
$this->element('link', array('xmlns' => 'http://www.w3.org/2005/Atom',
|
$this->element('link', array('xmlns' => 'http://www.w3.org/2005/Atom',
|
||||||
'rel' => 'http://api.friendfeed.com/2008/03#sup',
|
'rel' => 'http://api.friendfeed.com/2008/03#sup',
|
||||||
'href' => $suplink,
|
'href' => $suplink,
|
||||||
@ -547,23 +547,23 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
if (is_array($notice)) {
|
if (is_array($notice)) {
|
||||||
foreach ($notice as $n) {
|
foreach ($notice as $n) {
|
||||||
$entry = $this->twitter_rss_entry_array($n);
|
$entry = $this->twitterRssEntryArray($n);
|
||||||
$this->show_twitter_rss_item($entry);
|
$this->showTwitterRssItem($entry);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
$entry = $this->twitter_rss_entry_array($notice);
|
$entry = $this->twitterRssEntryArray($notice);
|
||||||
$this->show_twitter_rss_item($entry);
|
$this->showTwitterRssItem($entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_twitter_rss();
|
$this->endTwitterRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null)
|
function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('atom');
|
$this->initDocument('atom');
|
||||||
|
|
||||||
$this->element('title', null, $title);
|
$this->element('title', null, $title);
|
||||||
$this->element('id', null, $id);
|
$this->element('id', null, $id);
|
||||||
@ -594,14 +594,14 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_document('atom');
|
$this->endDocument('atom');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_rss_groups($group, $title, $link, $subtitle)
|
function showRssGroups($group, $title, $link, $subtitle)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('rss');
|
$this->initDocument('rss');
|
||||||
|
|
||||||
$this->element('title', null, $title);
|
$this->element('title', null, $title);
|
||||||
$this->element('link', null, $link);
|
$this->element('link', null, $link);
|
||||||
@ -611,17 +611,17 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
if (is_array($group)) {
|
if (is_array($group)) {
|
||||||
foreach ($group as $g) {
|
foreach ($group as $g) {
|
||||||
$twitter_group = $this->twitter_rss_group_array($g);
|
$twitter_group = $this->twitterRssGroupArray($g);
|
||||||
$this->show_twitter_rss_item($twitter_group);
|
$this->showTwitterRssItem($twitter_group);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($group->fetch()) {
|
while ($group->fetch()) {
|
||||||
$twitter_group = $this->twitter_rss_group_array($group);
|
$twitter_group = $this->twitterRssGroupArray($group);
|
||||||
$this->show_twitter_rss_item($twitter_group);
|
$this->showTwitterRssItem($twitter_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_twitter_rss();
|
$this->endTwitterRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ class ApiAction extends Action
|
|||||||
switch ($element) {
|
switch ($element) {
|
||||||
case 'sender':
|
case 'sender':
|
||||||
case 'recipient':
|
case 'recipient':
|
||||||
$this->show_twitter_xml_user($value, $element);
|
$this->showTwitterXmlUser($value, $element);
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
$this->element($element, null, common_xml_safe_str($value));
|
$this->element($element, null, common_xml_safe_str($value));
|
||||||
@ -679,11 +679,11 @@ class ApiAction extends Action
|
|||||||
$dmsg['sender_id'] = $message->from_profile;
|
$dmsg['sender_id'] = $message->from_profile;
|
||||||
$dmsg['text'] = trim($message->content);
|
$dmsg['text'] = trim($message->content);
|
||||||
$dmsg['recipient_id'] = $message->to_profile;
|
$dmsg['recipient_id'] = $message->to_profile;
|
||||||
$dmsg['created_at'] = $this->date_twitter($message->created);
|
$dmsg['created_at'] = $this->dateTwitter($message->created);
|
||||||
$dmsg['sender_screen_name'] = $from_profile->nickname;
|
$dmsg['sender_screen_name'] = $from_profile->nickname;
|
||||||
$dmsg['recipient_screen_name'] = $to_profile->nickname;
|
$dmsg['recipient_screen_name'] = $to_profile->nickname;
|
||||||
$dmsg['sender'] = $this->twitter_user_array($from_profile, false);
|
$dmsg['sender'] = $this->twitterUserArray($from_profile, false);
|
||||||
$dmsg['recipient'] = $this->twitter_user_array($to_profile, false);
|
$dmsg['recipient'] = $this->twitterUserArray($to_profile, false);
|
||||||
|
|
||||||
return $dmsg;
|
return $dmsg;
|
||||||
}
|
}
|
||||||
@ -725,24 +725,24 @@ class ApiAction extends Action
|
|||||||
|
|
||||||
function showSingleXmlDirectMessage($message)
|
function showSingleXmlDirectMessage($message)
|
||||||
{
|
{
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$dmsg = $this->directMessageArray($message);
|
$dmsg = $this->directMessageArray($message);
|
||||||
$this->showXmlDirectMessage($dmsg);
|
$this->showXmlDirectMessage($dmsg);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSingleJsonDirectMessage($message)
|
function showSingleJsonDirectMessage($message)
|
||||||
{
|
{
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$dmsg = $this->directMessageArray($message);
|
$dmsg = $this->directMessageArray($message);
|
||||||
$this->show_json_objects($dmsg);
|
$this->showJsonObjects($dmsg);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_atom_groups($group, $title, $id, $link, $subtitle=null, $selfuri=null)
|
function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('atom');
|
$this->initDocument('atom');
|
||||||
|
|
||||||
$this->element('title', null, $title);
|
$this->element('title', null, $title);
|
||||||
$this->element('id', null, $id);
|
$this->element('id', null, $id);
|
||||||
@ -766,143 +766,143 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->end_document('atom');
|
$this->endDocument('atom');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_json_timeline($notice)
|
function showJsonTimeline($notice)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
|
|
||||||
$statuses = array();
|
$statuses = array();
|
||||||
|
|
||||||
if (is_array($notice)) {
|
if (is_array($notice)) {
|
||||||
foreach ($notice as $n) {
|
foreach ($notice as $n) {
|
||||||
$twitter_status = $this->twitter_status_array($n);
|
$twitter_status = $this->twitterStatusArray($n);
|
||||||
array_push($statuses, $twitter_status);
|
array_push($statuses, $twitter_status);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
$twitter_status = $this->twitter_status_array($notice);
|
$twitter_status = $this->twitterStatusArray($notice);
|
||||||
array_push($statuses, $twitter_status);
|
array_push($statuses, $twitter_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_json_objects($statuses);
|
$this->showJsonObjects($statuses);
|
||||||
|
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_json_groups($group)
|
function showJsonGroups($group)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
|
|
||||||
$groups = array();
|
$groups = array();
|
||||||
|
|
||||||
if (is_array($group)) {
|
if (is_array($group)) {
|
||||||
foreach ($group as $g) {
|
foreach ($group as $g) {
|
||||||
$twitter_group = $this->twitter_group_array($g);
|
$twitter_group = $this->twitterGroupArray($g);
|
||||||
array_push($groups, $twitter_group);
|
array_push($groups, $twitter_group);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($group->fetch()) {
|
while ($group->fetch()) {
|
||||||
$twitter_group = $this->twitter_group_array($group);
|
$twitter_group = $this->twitterGroupArray($group);
|
||||||
array_push($groups, $twitter_group);
|
array_push($groups, $twitter_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_json_objects($groups);
|
$this->showJsonObjects($groups);
|
||||||
|
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_xml_groups($group)
|
function showXmlGroups($group)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('groups', array('type' => 'array'));
|
$this->elementStart('groups', array('type' => 'array'));
|
||||||
|
|
||||||
if (is_array($group)) {
|
if (is_array($group)) {
|
||||||
foreach ($group as $g) {
|
foreach ($group as $g) {
|
||||||
$twitter_group = $this->twitter_group_array($g);
|
$twitter_group = $this->twitterGroupArray($g);
|
||||||
$this->show_twitter_xml_group($twitter_group);
|
$this->showTwitterXmlGroup($twitter_group);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($group->fetch()) {
|
while ($group->fetch()) {
|
||||||
$twitter_group = $this->twitter_group_array($group);
|
$twitter_group = $this->twitterGroupArray($group);
|
||||||
$this->show_twitter_xml_group($twitter_group);
|
$this->showTwitterXmlGroup($twitter_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementEnd('groups');
|
$this->elementEnd('groups');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_twitter_xml_users($user)
|
function showTwitterXmlUsers($user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('users', array('type' => 'array'));
|
$this->elementStart('users', array('type' => 'array'));
|
||||||
|
|
||||||
if (is_array($user)) {
|
if (is_array($user)) {
|
||||||
foreach ($user as $u) {
|
foreach ($user as $u) {
|
||||||
$twitter_user = $this->twitter_user_array($u);
|
$twitter_user = $this->twitterUserArray($u);
|
||||||
$this->show_twitter_xml_user($twitter_user);
|
$this->showTwitterXmlUser($twitter_user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($user->fetch()) {
|
while ($user->fetch()) {
|
||||||
$twitter_user = $this->twitter_user_array($user);
|
$twitter_user = $this->twitterUserArray($user);
|
||||||
$this->show_twitter_xml_user($twitter_user);
|
$this->showTwitterXmlUser($twitter_user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementEnd('users');
|
$this->elementEnd('users');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_json_users($user)
|
function showJsonUsers($user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
|
|
||||||
$users = array();
|
$users = array();
|
||||||
|
|
||||||
if (is_array($user)) {
|
if (is_array($user)) {
|
||||||
foreach ($user as $u) {
|
foreach ($user as $u) {
|
||||||
$twitter_user = $this->twitter_user_array($u);
|
$twitter_user = $this->twitterUserArray($u);
|
||||||
array_push($users, $twitter_user);
|
array_push($users, $twitter_user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ($user->fetch()) {
|
while ($user->fetch()) {
|
||||||
$twitter_user = $this->twitter_user_array($user);
|
$twitter_user = $this->twitterUserArray($user);
|
||||||
array_push($users, $twitter_user);
|
array_push($users, $twitter_user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_json_objects($users);
|
$this->showJsonObjects($users);
|
||||||
|
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_single_json_group($group)
|
function showSingleJsonGroup($group)
|
||||||
{
|
{
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$twitter_group = $this->twitter_group_array($group);
|
$twitter_group = $this->twitterGroupArray($group);
|
||||||
$this->show_json_objects($twitter_group);
|
$this->showJsonObjects($twitter_group);
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_single_xml_group($group)
|
function show_single_xml_group($group)
|
||||||
{
|
{
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$twitter_group = $this->twitter_group_array($group);
|
$twitter_group = $this->twitterGroupArray($group);
|
||||||
$this->show_twitter_xml_group($twitter_group);
|
$this->showTwitterXmlGroup($twitter_group);
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function date_twitter($dt)
|
function dateTwitter($dt)
|
||||||
{
|
{
|
||||||
$dateStr = date('d F Y H:i:s', strtotime($dt));
|
$dateStr = date('d F Y H:i:s', strtotime($dt));
|
||||||
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
|
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
|
||||||
@ -910,24 +910,7 @@ class ApiAction extends Action
|
|||||||
return $d->format('D M d H:i:s O Y');
|
return $d->format('D M d H:i:s O Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Candidate for a general utility method somewhere?
|
function initDocument($type='xml')
|
||||||
function count_subscriptions($profile)
|
|
||||||
{
|
|
||||||
|
|
||||||
$count = 0;
|
|
||||||
$sub = new Subscription();
|
|
||||||
$sub->subscribed = $profile->id;
|
|
||||||
|
|
||||||
$count = $sub->find();
|
|
||||||
|
|
||||||
if ($count > 0) {
|
|
||||||
return $count - 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function init_document($type='xml')
|
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
@ -945,11 +928,11 @@ class ApiAction extends Action
|
|||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
header("Content-Type: application/rss+xml; charset=utf-8");
|
header("Content-Type: application/rss+xml; charset=utf-8");
|
||||||
$this->init_twitter_rss();
|
$this->initTwitterRss();
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||||
$this->init_twitter_atom();
|
$this->initTwitterAtom();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('Not a supported data format.'));
|
$this->clientError(_('Not a supported data format.'));
|
||||||
@ -959,7 +942,7 @@ class ApiAction extends Action
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function end_document($type='xml')
|
function endDocument($type='xml')
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
@ -974,10 +957,10 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->end_twitter_rss();
|
$this->endTwitterRss();
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$this->end_twitter_rss();
|
$this->endTwitterRss();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('Not a supported data format.'));
|
$this->clientError(_('Not a supported data format.'));
|
||||||
@ -1001,17 +984,17 @@ class ApiAction extends Action
|
|||||||
header('HTTP/1.1 '.$code.' '.$status_string);
|
header('HTTP/1.1 '.$code.' '.$status_string);
|
||||||
|
|
||||||
if ($format == 'xml') {
|
if ($format == 'xml') {
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
$this->element('error', null, $msg);
|
$this->element('error', null, $msg);
|
||||||
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
||||||
$this->elementEnd('hash');
|
$this->elementEnd('hash');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
} elseif ($format == 'json'){
|
} elseif ($format == 'json'){
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
||||||
print(json_encode($error_array));
|
print(json_encode($error_array));
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If user didn't request a useful format, throw a regular client error
|
// If user didn't request a useful format, throw a regular client error
|
||||||
@ -1034,21 +1017,21 @@ class ApiAction extends Action
|
|||||||
header('HTTP/1.1 '.$code.' '.$status_string);
|
header('HTTP/1.1 '.$code.' '.$status_string);
|
||||||
|
|
||||||
if ($content_type == 'xml') {
|
if ($content_type == 'xml') {
|
||||||
$this->init_document('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
$this->element('error', null, $msg);
|
$this->element('error', null, $msg);
|
||||||
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
$this->element('request', null, $_SERVER['REQUEST_URI']);
|
||||||
$this->elementEnd('hash');
|
$this->elementEnd('hash');
|
||||||
$this->end_document('xml');
|
$this->endDocument('xml');
|
||||||
} else {
|
} else {
|
||||||
$this->init_document('json');
|
$this->initDocument('json');
|
||||||
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
|
||||||
print(json_encode($error_array));
|
print(json_encode($error_array));
|
||||||
$this->end_document('json');
|
$this->endDocument('json');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_twitter_rss()
|
function initTwitterRss()
|
||||||
{
|
{
|
||||||
$this->startXML();
|
$this->startXML();
|
||||||
$this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom'));
|
$this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom'));
|
||||||
@ -1056,14 +1039,14 @@ class ApiAction extends Action
|
|||||||
Event::handle('StartApiRss', array($this));
|
Event::handle('StartApiRss', array($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
function end_twitter_rss()
|
function endTwitterRss()
|
||||||
{
|
{
|
||||||
$this->elementEnd('channel');
|
$this->elementEnd('channel');
|
||||||
$this->elementEnd('rss');
|
$this->elementEnd('rss');
|
||||||
$this->endXML();
|
$this->endXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_twitter_atom()
|
function initTwitterAtom()
|
||||||
{
|
{
|
||||||
$this->startXML();
|
$this->startXML();
|
||||||
// FIXME: don't hardcode the language here!
|
// FIXME: don't hardcode the language here!
|
||||||
@ -1073,21 +1056,21 @@ class ApiAction extends Action
|
|||||||
Event::handle('StartApiAtom', array($this));
|
Event::handle('StartApiAtom', array($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
function end_twitter_atom()
|
function endTwitterAtom()
|
||||||
{
|
{
|
||||||
$this->elementEnd('feed');
|
$this->elementEnd('feed');
|
||||||
$this->endXML();
|
$this->endXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_profile($profile, $content_type='xml', $notice=null, $includeStatuses=true)
|
function showProfile($profile, $content_type='xml', $notice=null, $includeStatuses=true)
|
||||||
{
|
{
|
||||||
$profile_array = $this->twitter_user_array($profile, $includeStatuses);
|
$profile_array = $this->twitterUserArray($profile, $includeStatuses);
|
||||||
switch ($content_type) {
|
switch ($content_type) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->show_twitter_xml_user($profile_array);
|
$this->showTwitterXmlUser($profile_array);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_objects($profile_array);
|
$this->showJsonObjects($profile_array);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->clientError(_('Not a supported data format.'));
|
$this->clientError(_('Not a supported data format.'));
|
||||||
@ -1155,7 +1138,7 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function source_link($source)
|
function sourceLink($source)
|
||||||
{
|
{
|
||||||
$source_name = _($source);
|
$source_name = _($source);
|
||||||
switch ($source) {
|
switch ($source) {
|
||||||
|
@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
|
|
||||||
define('TWITTER_SERVICE', 1); // Twitter is foreign_service ID 1
|
define('TWITTER_SERVICE', 1); // Twitter is foreign_service ID 1
|
||||||
|
|
||||||
function update_twitter_user($twitter_id, $screen_name)
|
function updateTwitter_user($twitter_id, $screen_name)
|
||||||
{
|
{
|
||||||
$uri = 'http://twitter.com/' . $screen_name;
|
$uri = 'http://twitter.com/' . $screen_name;
|
||||||
$fuser = new Foreign_user();
|
$fuser = new Foreign_user();
|
||||||
@ -115,7 +115,7 @@ function save_twitter_user($twitter_id, $screen_name)
|
|||||||
// Only update if Twitter screen name has changed
|
// Only update if Twitter screen name has changed
|
||||||
|
|
||||||
if ($fuser->nickname != $screen_name) {
|
if ($fuser->nickname != $screen_name) {
|
||||||
$result = update_twitter_user($twitter_id, $screen_name);
|
$result = updateTwitter_user($twitter_id, $screen_name);
|
||||||
|
|
||||||
common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
|
common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
|
||||||
"$fuser->id to $screen_name, was $fuser->nickname");
|
"$fuser->id to $screen_name, was $fuser->nickname");
|
||||||
|
@ -246,7 +246,7 @@ class RealtimePlugin extends Plugin
|
|||||||
|
|
||||||
$act = new ApiAction('/dev/null');
|
$act = new ApiAction('/dev/null');
|
||||||
|
|
||||||
$arr = $act->twitter_status_array($notice, true);
|
$arr = $act->twitterStatusArray($notice, true);
|
||||||
$arr['url'] = $notice->bestUrl();
|
$arr['url'] = $notice->bestUrl();
|
||||||
$arr['html'] = htmlspecialchars($notice->rendered);
|
$arr['html'] = htmlspecialchars($notice->rendered);
|
||||||
$arr['source'] = htmlspecialchars($arr['source']);
|
$arr['source'] = htmlspecialchars($arr['source']);
|
||||||
|
Loading…
Reference in New Issue
Block a user