123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class EnjitQueueHandler extends QueueHandler
- {
- function transport()
- {
- return 'enjit';
- }
- function handle($notice)
- {
- $profile = Profile::getKV($notice->profile_id);
- $this->log(LOG_INFO, "Posting Notice ".$notice->id." from ".$profile->nickname);
- if ( ! $notice->is_local ) {
- $this->log(LOG_INFO, "Skipping remote notice");
- return "skipped";
- }
-
-
-
- $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
- $msg = $profile->nickname . ': ' . $notice->content;
- $atom = "<entry xmlns='http://www.w3.org/2005/Atom'>\n";
- $atom .= "<apisource>".common_config('enjit','source')."</apisource>\n";
- $atom .= "<source>\n";
- $atom .= "<title>" . $profile->nickname . " - " . common_config('site', 'name') . "</title>\n";
- $atom .= "<link href='" . $profile->profileurl . "'/>\n";
- $atom .= "<link rel='self' type='application/rss+xml' href='" . common_local_url('userrss', array('nickname' => $profile->nickname)) . "'/>\n";
- $atom .= "<author><name>" . $profile->nickname . "</name></author>\n";
- $atom .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
- $atom .= "</source>\n";
- $atom .= "<title>" . htmlspecialchars($msg) . "</title>\n";
- $atom .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
- $atom .= "<link rel='alternate' href='" . $noticeurl . "' />\n";
- $atom .= "<id>". $notice->uri . "</id>\n";
- $atom .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
- $atom .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
- $atom .= "</entry>\n";
- $url = common_config('enjit', 'apiurl') . "/submit/". common_config('enjit','apikey');
- $data = array(
- 'msg' => $atom,
- );
-
-
-
- $request = HTTPClient::start();
- $response = $request->post($url, null, $data);
- return $response->isOk();
- }
- }
|