- $action: the current action
- &$xrdsoutputter - XRDSOutputter object to write to
+StartHostMetaLinks: Start /.well-known/host-meta links
+- &links: array containing the links elements to be written
+
+EndHostMetaLinks: End /.well-known/host-meta links
+- &links: array containing the links elements to be written
+
StartCheckPassword: Check a username/password
- $nickname: The nickname to check
- $password: The password to check
EndShowContentLicense: Showing the default license for content
- $action: the current action
+GetImTransports: Get IM transports that are available
+- &$transports: append your transport to this array like so: $transports[transportName]=array('display'=>display)
+
+NormalizeImScreenname: Normalize an IM screenname
+- $transport: transport the screenname is on
+- &$screenname: screenname to be normalized
+
+ValidateImScreenname: Validate an IM screenname
+- $transport: transport the screenname is on
+- $screenname: screenname to be validated
+- $valid: is the screenname valid?
+
+SendImConfirmationCode: Send a confirmation code to confirm a user owns an IM screenname
+- $transport: transport the screenname exists on
+- $screenname: screenname being confirmed
+- $code: confirmation code for confirmation URL
+- $user: user requesting the confirmation
+
StartUserRegister: When a new user is being registered
- &$profile: new profile data (no ID)
- &$user: new user account (no ID or URI)
EndShowPageTitle: when done showing the page title <h1>
- $action: action being shown
+
+ StartDeleteOwnNotice: when a user starts to delete their own notice
+ - $user: the user doing the delete
+ - $notice: the notice being deleted
+
+ EndDeleteOwnNotice: when a user has deleted their own notice
+ - $user: the user doing the delete
+ - $notice: the notice being deleted
README
------
- StatusNet 0.9.4 "Orange Crush"
- 16 August 2010
+ StatusNet 0.9.5 "What's The Frequency, Kenneth?"
+ 10 September 2010
This is the README file for StatusNet, the Open Source microblogging
platform. It includes installation instructions, descriptions of
parameters correctly so that both the SSL server and the
"normal" server can access the session cookie and
preferably other cookies as well.
-shorturllength: Length of URL at which URLs in a message exceeding 140
- characters will be sent to the user's chosen
- shortening service.
+shorturllength: ignored. See 'url' section below.
dupelimit: minimum time allowed for one person to say the same thing
twice. Default 60s. Anything lower is considered a user
or UI error.
'search', 'message', 'settings', 'admin'. Ignored when site
is private, in which case the entire site ('/') is disallowed.
+url
+---
+
+Everybody loves URL shorteners. These are some options for fine-tuning
+how and when the server shortens URLs.
+
+shortener: URL shortening service to use by default. Users can override
+ individually. 'ur1.ca' by default.
+maxlength: If an URL is strictly longer than this limit, it will be
+ shortened. Note that the URL shortener service may return an
+ URL longer than this limit. Defaults to 25. Users can
+ override. If set to 0, all URLs will be shortened.
+maxnoticelength: If a notice is strictly longer than this limit, all
+ URLs in the notice will be shortened. Users can override.
+ -1 means the text limit for notices.
+
Plugins
=======
if ($f2p->find()) {
while ($f2p->fetch()) {
$f = File::staticGet($f2p->file_id);
- $att[] = clone($f);
+ if ($f) {
+ $att[] = clone($f);
+ }
}
}
return $att;
function getStreamByIds($ids)
{
- $cache = common_memcache();
+ $cache = Cache::instance();
if (!empty($cache)) {
$notices = array();
$c = self::memcache();
if (!empty($c)) {
- $ni = $c->get(common_cache_key('notice:who_gets:'.$this->id));
+ $ni = $c->get(Cache::key('notice:who_gets:'.$this->id));
if ($ni !== false) {
return $ni;
}
if (!empty($c)) {
// XXX: pack this data better
- $c->set(common_cache_key('notice:who_gets:'.$this->id), $ni);
+ $c->set(Cache::key('notice:who_gets:'.$this->id), $ni);
}
return $ni;
function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0)
{
- $cache = common_memcache();
+ $cache = Cache::instance();
if (empty($cache) ||
$since_id != 0 || $max_id != 0 ||
$max_id)));
}
- $idkey = common_cache_key($cachekey);
+ $idkey = Cache::key($cachekey);
$idstr = $cache->get($idkey);
function repeatStream($limit=100)
{
- $cache = common_memcache();
+ $cache = Cache::instance();
if (empty($cache)) {
$ids = $this->_repeatStreamDirect($limit);
} else {
- $idstr = $cache->get(common_cache_key('notice:repeats:'.$this->id));
+ $idstr = $cache->get(Cache::key('notice:repeats:'.$this->id));
if ($idstr !== false) {
$ids = explode(',', $idstr);
} else {
$ids = $this->_repeatStreamDirect(100);
- $cache->set(common_cache_key('notice:repeats:'.$this->id), implode(',', $ids));
+ $cache->set(Cache::key('notice:repeats:'.$this->id), implode(',', $ids));
}
if ($limit < 100) {
// We do a max of 100, so slice down to limit
if ($tag->find()) {
while ($tag->fetch()) {
- self::blow('profile:notice_ids_tagged:%d:%s', $this->profile_id, common_keyize($tag->tag));
- self::blow('profile:notice_ids_tagged:%d:%s;last', $this->profile_id, common_keyize($tag->tag));
- self::blow('notice_tag:notice_ids:%s', common_keyize($tag->tag));
- self::blow('notice_tag:notice_ids:%s;last', common_keyize($tag->tag));
+ self::blow('profile:notice_ids_tagged:%d:%s', $this->profile_id, Cache::keyize($tag->tag));
+ self::blow('profile:notice_ids_tagged:%d:%s;last', $this->profile_id, Cache::keyize($tag->tag));
+ self::blow('notice_tag:notice_ids:%s', Cache::keyize($tag->tag));
+ self::blow('notice_tag:notice_ids:%s;last', Cache::keyize($tag->tag));
$tag->delete();
}
}
exit(1);
}
+class ApiValidationException extends Exception { }
+
/**
* Contains most of the Twitter-compatible API output functions.
*
// StatusNet-specific
- $twitter_user['statusnet:profile_url'] = $profile->profileurl;
+ $twitter_user['statusnet_profile_url'] = $profile->profileurl;
return $twitter_user;
}
// StatusNet-specific
- $twitter_status['statusnet:html'] = $notice->rendered;
+ $twitter_status['statusnet_html'] = $notice->rendered;
return $twitter_status;
}
$this->showTwitterXmlStatus($value, 'retweeted_status');
break;
default:
- $this->element($element, null, $value);
+ if (strncmp($element, 'statusnet_', 10) == 0) {
+ $this->element('statusnet:'.substr($element, 10), null, $value);
+ } else {
+ $this->element($element, null, $value);
+ }
}
}
$this->elementEnd($tag);
foreach($twitter_user as $element => $value) {
if ($element == 'status') {
$this->showTwitterXmlStatus($twitter_user['status']);
+ } else if (strncmp($element, 'statusnet_', 10) == 0) {
+ $this->element('statusnet:'.substr($element, 10), null, $value);
} else {
$this->element($element, null, $value);
}
//exit with 200 response, if this is checking fancy from the installer
if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; }
- define('STATUSNET_VERSION', '0.9.4');
+ define('STATUSNET_VERSION', '0.9.5');
define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility
- define('STATUSNET_CODENAME', 'Orange Crush');
+ define('STATUSNET_CODENAME', 'What\'s The Frequency, Kenneth?');
define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48);
# global configuration object
require_once('PEAR.php');
+require_once('PEAR/Exception.php');
require_once('DB/DataObject.php');
require_once('DB/DataObject/Cast.php'); # for dates
require_once INSTALLDIR.'/lib/clientexception.php';
require_once INSTALLDIR.'/lib/serverexception.php';
+
+//set PEAR error handling to use regular PHP exceptions
+function PEAR_ErrorToPEAR_Exception($err)
+{
+ //DB_DataObject throws error when an empty set would be returned
+ //That behavior is weird, and not how the rest of StatusNet works.
+ //So just ignore those errors.
+ if ($err->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
+ return;
+ }
+ if ($err->getCode()) {
+ throw new PEAR_Exception($err->getMessage(), $err->getCode());
+ }
+ throw new PEAR_Exception($err->getMessage());
+}
+PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'PEAR_ErrorToPEAR_Exception');
+
try {
StatusNet::init(@$server, @$path, @$conffile);
} catch (NoConfigException $e) {
}
/**
- * Calls Twitter's /statuses/friends_timeline API method
+ * Calls Twitter's /statuses/home_timeline API method
*
* @param int $since_id show statuses after this id
* @param int $max_id show statuses before this id
*
* @return mixed an array of statuses
*/
- function statusesFriendsTimeline($since_id = null, $max_id = null,
- $cnt = null, $page = null)
+ function statusesHomeTimeline($since_id = null, $max_id = null,
+ $cnt = null, $page = null)
{
- $url = 'https://twitter.com/statuses/friends_timeline.json';
- $params = array('since_id' => $since_id,
- 'max_id' => $max_id,
- 'count' => $cnt,
- 'page' => $page);
- $qry = http_build_query($params);
+ $url = 'https://twitter.com/statuses/home_timeline.json';
- if (!empty($qry)) {
- $url .= "?$qry";
+ $params = array('include_entities' => 'true');
+
+ if (!empty($since_id)) {
+ $params['since_id'] = $since_id;
+ }
+ if (!empty($max_id)) {
+ $params['max_id'] = $max_id;
+ }
+ if (!empty($cnt)) {
+ $params['count'] = $cnt;
+ }
+ if (!empty($page)) {
+ $params['page'] = $page;
}
- $response = $this->oAuthGet($url);
+ $response = $this->oAuthGet($url, $params);
$statuses = json_decode($response);
return $statuses;
}
+ /**
+ * Calls Twitter's /statuses/home_timeline API method
+ *
+ * @param int $since_id show statuses after this id
+ * @param int $max_id show statuses before this id
+ * @param int $cnt number of statuses to show
+ * @param int $page page number
+ *
+ * @return mixed an array of statuses, similar to friends_timeline but including retweets
+ */
+ function statusesHomeTimeline($since_id = null, $max_id = null,
+ $cnt = null, $page = null)
+ {
+
+ $url = 'https://twitter.com/statuses/home_timeline.json';
+ $params = array('since_id' => $since_id,
+ 'max_id' => $max_id,
+ 'count' => $cnt,
+ 'page' => $page);
+ $qry = http_build_query($params);
+
+ if (!empty($qry)) {
+ $url .= "?$qry";
+ }
+
+ $response = $this->oAuthGet($url);
+ $statuses = json_decode($response);
+ return $statuses;
+ }
+
/**
* Calls Twitter's /statuses/friends API method
*
{
$url = "https://twitter.com/statuses/friends.json";
- $params = array('id' => $id,
- 'user_id' => $user_id,
- 'screen_name' => $screen_name,
- 'page' => $page);
- $qry = http_build_query($params);
+ $params = array();
- if (!empty($qry)) {
- $url .= "?$qry";
+ if (!empty($id)) {
+ $params['id'] = $id;
}
- $response = $this->oAuthGet($url);
+ if (!empty($user_id)) {
+ $params['user_id'] = $user_id;
+ }
+
+ if (!empty($screen_name)) {
+ $params['screen_name'] = $screen_name;
+ }
+
+ if (!empty($page)) {
+ $params['page'] = $page;
+ }
+
+ $response = $this->oAuthGet($url, $params);
$friends = json_decode($response);
return $friends;
}
{
$url = "https://twitter.com/friends/ids.json";
- $params = array('id' => $id,
- 'user_id' => $user_id,
- 'screen_name' => $screen_name,
- 'page' => $page);
- $qry = http_build_query($params);
+ $params = array();
- if (!empty($qry)) {
- $url .= "?$qry";
+ if (!empty($id)) {
+ $params['id'] = $id;
}
- $response = $this->oAuthGet($url);
+ if (!empty($user_id)) {
+ $params['user_id'] = $user_id;
+ }
+
+ if (!empty($screen_name)) {
+ $params['screen_name'] = $screen_name;
+ }
+
+ if (!empty($page)) {
+ $params['page'] = $page;
+ }
+
+ $response = $this->oAuthGet($url, $params);
$ids = json_decode($response);
return $ids;
}
+ /**
+ * Calls Twitter's /statuses/retweet/id.json API method
+ *
+ * @param int $id id of the notice to retweet
+ *
+ * @return retweeted status
+ */
+
+ function statusesRetweet($id)
+ {
+ $url = "http://api.twitter.com/1/statuses/retweet/$id.json";
+ $response = $this->oAuthPost($url);
+ $status = json_decode($response);
+ return $status;
+ }
+
+ /**
+ * Calls Twitter's /favorites/create API method
+ *
+ * @param int $id ID of the status to favorite
+ *
+ * @return object faved status
+ */
+
+ function favoritesCreate($id)
+ {
+ $url = "http://api.twitter.com/1/favorites/create/$id.json";
+ $response = $this->oAuthPost($url);
+ $status = json_decode($response);
+ return $status;
+ }
+
+ /**
+ * Calls Twitter's /favorites/destroy API method
+ *
+ * @param int $id ID of the status to unfavorite
+ *
+ * @return object unfaved status
+ */
+
+ function favoritesDestroy($id)
+ {
+ $url = "http://api.twitter.com/1/favorites/destroy/$id.json";
+ $response = $this->oAuthPost($url);
+ $status = json_decode($response);
+ return $status;
+ }
+
+ /**
+ * Calls Twitter's /statuses/destroy API method
+ *
+ * @param int $id ID of the status to destroy
+ *
+ * @return object destroyed
+ */
+
+ function statusesDestroy($id)
+ {
+ $url = "http://api.twitter.com/1/statuses/destroy/$id.json";
+ $response = $this->oAuthPost($url);
+ $status = json_decode($response);
+ return $status;
+ }
}