summaryrefslogtreecommitdiff
path: root/lib/apiaction.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/apiaction.php')
-rw-r--r--lib/apiaction.php120
1 files changed, 82 insertions, 38 deletions
diff --git a/lib/apiaction.php b/lib/apiaction.php
index f87b04611..80a8a08d1 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -32,6 +32,67 @@
* @link http://status.net/
*/
+/* External API usage documentation. Please update when you change how the API works. */
+
+/*! @mainpage StatusNet REST API
+
+ @section Introduction
+
+ Some explanatory text about the API would be nice.
+
+ @section API Methods
+
+ @subsection timelinesmethods_sec Timeline Methods
+
+ @li @ref publictimeline
+ @li @ref friendstimeline
+
+ @subsection statusmethods_sec Status Methods
+
+ @li @ref statusesupdate
+
+ @subsection usermethods_sec User Methods
+
+ @subsection directmessagemethods_sec Direct Message Methods
+
+ @subsection friendshipmethods_sec Friendship Methods
+
+ @subsection socialgraphmethods_sec Social Graph Methods
+
+ @subsection accountmethods_sec Account Methods
+
+ @subsection favoritesmethods_sec Favorites Methods
+
+ @subsection blockmethods_sec Block Methods
+
+ @subsection oauthmethods_sec OAuth Methods
+
+ @subsection helpmethods_sec Help Methods
+
+ @subsection groupmethods_sec Group Methods
+
+ @page apiroot API Root
+
+ The URLs for methods referred to in this API documentation are
+ relative to the StatusNet API root. The API root is determined by the
+ site's @b server and @b path variables, which are generally specified
+ in config.php. For example:
+
+ @code
+ $config['site']['server'] = 'example.org';
+ $config['site']['path'] = 'statusnet'
+ @endcode
+
+ The pattern for a site's API root is: @c protocol://server/path/api E.g:
+
+ @c http://example.org/statusnet/api
+
+ The @b path can be empty. In that case the API root would simply be:
+
+ @c http://example.org/api
+
+*/
+
if (!defined('STATUSNET')) {
exit(1);
}
@@ -111,6 +172,7 @@ class ApiAction extends Action
function handle($args)
{
+ header('Access-Control-Allow-Origin: *');
parent::handle($args);
}
@@ -260,7 +322,23 @@ class ApiAction extends Action
$twitter_status['created_at'] = $this->dateTwitter($notice->created);
$twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
intval($notice->reply_to) : null;
- $twitter_status['source'] = $this->sourceLink($notice->source);
+
+ $source = null;
+
+ $ns = $notice->getSource();
+ if ($ns) {
+ if (!empty($ns->name) && !empty($ns->url)) {
+ $source = '<a href="'
+ . htmlspecialchars($ns->url)
+ . '" rel="nofollow">'
+ . htmlspecialchars($ns->name)
+ . '</a>';
+ } else {
+ $source = $ns->code;
+ }
+ }
+
+ $twitter_status['source'] = $source;
$twitter_status['id'] = intval($notice->id);
$replier_profile = null;
@@ -1074,6 +1152,7 @@ class ApiAction extends Action
$this->initTwitterAtom();
break;
default:
+ // TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
break;
}
@@ -1102,6 +1181,7 @@ class ApiAction extends Action
$this->endTwitterRss();
break;
default:
+ // TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
break;
}
@@ -1218,6 +1298,7 @@ class ApiAction extends Action
$this->showJsonObjects($profile_array);
break;
default:
+ // TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
return;
}
@@ -1298,43 +1379,6 @@ class ApiAction extends Action
}
}
- function sourceLink($source)
- {
- $source_name = _($source);
- switch ($source) {
- case 'web':
- case 'xmpp':
- case 'mail':
- case 'omb':
- case 'api':
- break;
- default:
-
- $name = null;
- $url = null;
-
- $ns = Notice_source::staticGet($source);
-
- if ($ns) {
- $name = $ns->name;
- $url = $ns->url;
- } else {
- $app = Oauth_application::staticGet('name', $source);
- if ($app) {
- $name = $app->name;
- $url = $app->source_url;
- }
- }
-
- if (!empty($name) && !empty($url)) {
- $source_name = '<a href="' . $url . '">' . $name . '</a>';
- }
-
- break;
- }
- return $source_name;
- }
-
/**
* Returns query argument or default value if not found. Certain
* parameters used throughout the API are lightly scrubbed and