twitter_subscriptions/init.php

33 lines
1016 B
PHP
Raw Normal View History

2019-05-01 18:26:42 +02:00
<?php
class Twitter_Subscription extends Plugin {
private $host;
function about() {
return array(1.0,
"Allows subscribing to Twitter feeds using twitrss.me service",
"ggrandou");
}
function init($host) {
$this->host = $host;
$host->add_hook($host::HOOK_SUBSCRIBE_FEED, $this);
}
function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) {
if (preg_match("/^https:\/\/twitter\.com\/([^\/]+)$/", $url, $matches) === 1) {
$user = $matches[1];
$contents = "<html><head>";
$contents .= "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Tweets\" href=\"https://twitrss.me/twitter_user_to_rss/?user=$user\" />";
$contents .= "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Tweets+Responses\" href=\"https://twitrss.me/twitter_user_to_rss/?user=$user&replies=on\" />";
$contents .= "</head><body></body></html>";
//error_log(print_r($contents, TRUE));
}
return $contents;
}
function api_version() {
return 2;
}
}
?>