]> git.wh0rd.org - tt-rss.git/commitdiff
remove pubsubhubbub: dead
authorAndrew Dolgov <noreply@fakecake.org>
Tue, 16 May 2017 07:41:20 +0000 (10:41 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Tue, 16 May 2017 07:41:20 +0000 (10:41 +0300)
12 files changed:
classes/api.php
classes/handler/public.php
classes/pref/feeds.php
classes/rpc.php
classes/rssutils.php
config.php-dist
include/functions.php
include/sanity_check.php
include/sanity_config.php
js/functions.js
lib/pubsubhubbub/Publisher.php [deleted file]
lib/pubsubhubbub/Subscriber.php [deleted file]

index 220d37981e2b4159cacb23f9db95a86491989c75..0176e167230a5d1740bb6055bfca57d0bc5f5df1 100644 (file)
@@ -301,17 +301,6 @@ class API extends Handler {
                                }
                        }
 
-                       if ($num_updated > 0 && $field == "published") {
-                               if (PUBSUBHUBBUB_HUB) {
-                                       $rss_link = get_self_url_prefix() .
-                                               "/public.php?op=rss&id=-2&key=" .
-                                               get_feed_access_key(-2, false);
-
-                                       $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
-                                       $p->publish_update($rss_link);
-                               }
-                       }
-
                        $this->wrap(self::STATUS_OK, array("status" => "OK",
                                "updated" => $num_updated));
 
index d525bc54c001405ac565233c9db842c9a126ad5f..403e20ca588bc3d4220500c7b53383dfd9b4b8a0 100644 (file)
@@ -105,11 +105,6 @@ class Handler_Public extends Handler {
                        $tpl->setVariable('VERSION', VERSION, true);
                        $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
 
-                       if (PUBSUBHUBBUB_HUB && $feed == -2) {
-                               $tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true);
-                               $tpl->addBlock('feed_hub');
-                       }
-
                        $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
                        while ($line = $this->dbh->fetch_assoc($result)) {
 
@@ -195,10 +190,6 @@ class Handler_Public extends Handler {
                        $feed['version'] = VERSION;
                        $feed['feed_url'] = $feed_self_url;
 
-                       if (PUBSUBHUBBUB_HUB && $feed == -2) {
-                               $feed['hub_url'] = PUBSUBHUBBUB_HUB;
-                       }
-
                        $feed['self_url'] = get_self_url_prefix();
 
                        $feed['articles'] = array();
@@ -305,71 +296,6 @@ class Handler_Public extends Handler {
                print "</select>";
        }
 
-       function pubsub() {
-               $mode = $this->dbh->escape_string($_REQUEST['hub_mode']);
-               if (!$mode) $mode = $this->dbh->escape_string($_REQUEST['hub.mode']);
-
-               $feed_id = (int) $this->dbh->escape_string($_REQUEST['id']);
-               $feed_url = $this->dbh->escape_string($_REQUEST['hub_topic']);
-
-               if (!$feed_url) $feed_url = $this->dbh->escape_string($_REQUEST['hub.topic']);
-
-               if (!PUBSUBHUBBUB_ENABLED) {
-                       header('HTTP/1.0 404 Not Found');
-                       echo "404 Not found (Disabled by server)";
-                       return;
-               }
-
-               // TODO: implement hub_verifytoken checking
-               // TODO: store requested rel=self or whatever for verification
-               // (may be different from stored feed url) e.g. http://url/ or http://url
-
-               $result = $this->dbh->query("SELECT feed_url FROM ttrss_feeds
-                       WHERE id = '$feed_id'");
-
-               if ($this->dbh->num_rows($result) != 0) {
-
-                       $check_feed_url = $this->dbh->fetch_result($result, 0, "feed_url");
-
-                       // ignore url checking for the time being
-                       if ($check_feed_url && (true || $check_feed_url == $feed_url || !$feed_url)) {
-                               if ($mode == "subscribe") {
-
-                                       $this->dbh->query("UPDATE ttrss_feeds SET pubsub_state = 2
-                                               WHERE id = '$feed_id'");
-
-                                       print $_REQUEST['hub_challenge'];
-                                       return;
-
-                               } else if ($mode == "unsubscribe") {
-
-                                       $this->dbh->query("UPDATE ttrss_feeds SET pubsub_state = 0
-                                               WHERE id = '$feed_id'");
-
-                                       print $_REQUEST['hub_challenge'];
-                                       return;
-
-                               } else if (!$mode) {
-
-                                       // Received update ping, schedule feed update.
-                                       //update_rss_feed($feed_id, true, true);
-
-                                       $this->dbh->query("UPDATE ttrss_feeds SET
-                                               last_update_started = '1970-01-01',
-                                               last_updated = '1970-01-01' WHERE id = '$feed_id'");
-
-                               }
-                       } else {
-                               header('HTTP/1.0 404 Not Found');
-                               echo "404 Not found (URL check failed)";
-                       }
-               } else {
-                       header('HTTP/1.0 404 Not Found');
-                       echo "404 Not found (Feed not found)";
-               }
-
-       }
-
        function logout() {
                logout_user();
                header("Location: index.php");
index 002d56aeb95fe5954d1a1fbf3eaa6634e7a6cc32..785451707a412f7fda6d5990431f26d7d4b00dcd 100755 (executable)
@@ -784,20 +784,8 @@ class Pref_Feeds extends Handler_Protected {
                        <button class=\"danger\" dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
                                __('Unsubscribe')."</button>";
 
-               if (PUBSUBHUBBUB_ENABLED) {
-                       $pubsub_state = $this->dbh->fetch_result($result, 0, "pubsub_state");
-                       $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\"";
-
-                       print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled
-                                       onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates').
-                                       "</button>";
-               }
-
                print "</div>";
 
-               print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">".
-                       __('Resets PubSubHubbub subscription status for push-enabled feeds.')."</div>";
-
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button>
                        <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button>
                </div>";
@@ -1118,16 +1106,6 @@ class Pref_Feeds extends Handler_Protected {
                return;
        }
 
-       function resetPubSub() {
-
-               $ids = $this->dbh->escape_string($_REQUEST["ids"]);
-
-               $this->dbh->query("UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids)
-                       AND owner_uid = " . $_SESSION["uid"]);
-
-               return;
-       }
-
        function remove() {
 
                $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
index 70ee423af5bea8e6329e280491f8e0d8746fb57e..7d39261b13d8973ed1e0dd943e74f0be6116955f 100755 (executable)
@@ -274,20 +274,7 @@ class RPC extends Handler_Protected {
                        published = $pub, last_published = NOW()
                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
-               $pubsub_result = false;
-
-               if (PUBSUBHUBBUB_HUB) {
-                       $rss_link = get_self_url_prefix() .
-                               "/public.php?op=rss&id=-2&key=" .
-                               get_feed_access_key(-2, false);
-
-                       $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
-
-                       $pubsub_result = $p->publish_update($rss_link);
-               }
-
-               print json_encode(array("message" => "UPDATE_COUNTERS",
-                       "pubsub_result" => $pubsub_result));
+               print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
 
        function getAllCounters() {
@@ -618,16 +605,6 @@ class RPC extends Handler_Protected {
                        published = NOT published,last_published = NOW()
                        WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
                }
-
-               if (PUBSUBHUBBUB_HUB) {
-                       $rss_link = get_self_url_prefix() .
-                               "/public.php?op=rss&id=-2&key=" .
-                               get_feed_access_key(-2, false);
-
-                       $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
-
-                       /* $pubsub_result = */ $p->publish_update($rss_link);
-               }
        }
 
        function getlinktitlebyid() {
index 1c8846e4e1d675b1606f994133edad7d48c76e90..e6fe39592c00768d48f41e427056ccc128298d05 100644 (file)
@@ -310,14 +310,12 @@ class RSSUtils {
                $result = db_query("SELECT id,update_interval,auth_login,
                        feed_url,auth_pass,cache_images,
                        mark_unread_on_update, owner_uid,
-                       pubsub_state, auth_pass_encrypted,
-                       feed_language
+                       auth_pass_encrypted, feed_language
                        FROM ttrss_feeds WHERE id = '$feed'");
 
                $owner_uid = db_fetch_result($result, 0, "owner_uid");
                $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result,
                        0, "mark_unread_on_update"));
-               $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
                $auth_pass_encrypted = sql_bool_to_bool(db_fetch_result($result,
                        0, "auth_pass_encrypted"));
 
@@ -530,55 +528,6 @@ class RSSUtils {
                                return; // no articles
                        }
 
-                       if ($pubsub_state != 2 && PUBSUBHUBBUB_ENABLED) {
-
-                               _debug("checking for PUSH hub...", $debug_enabled);
-
-                               $feed_hub_url = false;
-
-                               $links = $rss->get_links('hub');
-
-                               if ($links && is_array($links)) {
-                                       foreach ($links as $l) {
-                                               $feed_hub_url = $l;
-                                               break;
-                                       }
-                               }
-
-                               _debug("feed hub url: $feed_hub_url", $debug_enabled);
-
-                               $feed_self_url = $fetch_url;
-
-                               $links = $rss->get_links('self');
-
-                               if ($links && is_array($links)) {
-                                       foreach ($links as $l) {
-                                               $feed_self_url = $l;
-                                               break;
-                                       }
-                               }
-
-                               _debug("feed self url = $feed_self_url");
-
-                               if ($feed_hub_url && $feed_self_url && function_exists('curl_init') &&
-                                       !ini_get("open_basedir")) {
-
-                                       require_once 'lib/pubsubhubbub/Subscriber.php';
-
-                                       $callback_url = get_self_url_prefix() .
-                                               "/public.php?op=pubsub&id=$feed";
-
-                                       $s = new Pubsubhubbub\Subscriber\Subscriber($feed_hub_url, $callback_url);
-
-                                       $rc = $s->subscribe($feed_self_url);
-
-                                       _debug("feed hub url found, subscribe request sent. [rc=$rc]", $debug_enabled);
-
-                                       db_query("UPDATE ttrss_feeds SET pubsub_state = 1
-                                               WHERE id = '$feed'");
-                               }
-                       }
-
                        _debug("processing articles...", $debug_enabled);
 
                        $tstart = time();
@@ -960,16 +909,6 @@ class RSSUtils {
                                                                $last_read_qpart, $marked, $published, '$score', '', '',
                                                                '', $last_marked, $last_published)");
 
-                                               if (PUBSUBHUBBUB_HUB && $published == 'true') {
-                                                       $rss_link = get_self_url_prefix() .
-                                                               "/public.php?op=rss&id=-2&key=" .
-                                                               get_feed_access_key(-2, false, $owner_uid);
-
-                                                       $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
-
-                                                       /* $pubsub_result = */ $p->publish_update($rss_link);
-                                               }
-
                                                $result = db_query(
                                                        "SELECT int_id FROM ttrss_user_entries WHERE
                                                                ref_id = '$ref_id' AND owner_uid = '$owner_uid' AND
index c86af943be85da8c1b4be0f3fa75b2a88a0dd4c3..38a56f115a431aa7a70ff35addd0eb3d386d668c 100644 (file)
        // intervals is disabled and all articles (which are not starred) 
        // older than this amount of days are purged.
 
-       // *** PubSubHubbub settings ***
-
-       define('PUBSUBHUBBUB_HUB', '');
-       // URL to a PubSubHubbub-compatible hub server. If defined, "Published
-       // articles" generated feed would automatically become PUSH-enabled.
-
-       define('PUBSUBHUBBUB_ENABLED', false);
-       // Enable client PubSubHubbub support in tt-rss. When disabled, tt-rss
-       // won't try to subscribe to PUSH feed updates.
-
        // ****************************
        // *** Sphinx search plugin ***
        // ****************************
index 3ea1035cb0050b3bf989d1b26e4e8945ccbd3631..a664212b2e9d896f703a2084e0bf2085b151001d 100644 (file)
        define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)');
        ini_set('user_agent', SELF_USER_AGENT);
 
-       require_once 'lib/pubsubhubbub/Publisher.php';
-
        $schema_version = false;
 
        function _debug_suppress($suppress) {
index 12cc5579df02316f2b72db48de4aac9d36c7553f..83ff367372e5aadd07d252f75e9bb2cd562b80f8 100755 (executable)
                                array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss.");
                        }
 
-                       if ((PUBSUBHUBBUB_HUB || PUBSUBHUBBUB_ENABLED) && !function_exists("curl_init")) {
-                               array_push($errors, "PHP support for CURL is required for PubSubHubbub.");
-                       }
-
                        if (!class_exists("DOMDocument")) {
                                array_push($errors, "PHP support for DOMDocument is required, but was not found.");
                        }
index 797b74edabdb5f1b143dc627153e938c2874a041..0e9944361d88ac06f66129ba8b139f878190ae59 100644 (file)
@@ -1,3 +1,3 @@
-<?php # This file has been generated at:  Tue, Dec 1, 2015 10:11:18 AM
+<?php # This file has been generated at:  Tue, May 16, 2017 10:37:57 AM
 define('GENERATED_CONFIG_CHECK', 26);
-$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'FEED_CRYPT_KEY', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_SERVER', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'SMTP_SECURE', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?>
+$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'FEED_CRYPT_KEY', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_SERVER', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'SMTP_SECURE', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?>
index b33c23dc13035073bd6a0e7ccf890652d67637c1..934f69e96c7f5db1aa5ea9ce1780577d3de4b636 100755 (executable)
@@ -1123,27 +1123,6 @@ function quickAddFilter() {
 
 }
 
-function resetPubSub(feed_id, title) {
-
-       var msg = __("Reset subscription? Tiny Tiny RSS will try to subscribe to the notification hub again on next feed update.").replace("%s", title);
-
-       if (title == undefined || confirm(msg)) {
-               notify_progress("Loading, please wait...");
-
-               var query = "?op=pref-feeds&quiet=1&method=resetPubSub&ids=" + feed_id;
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-                               dijit.byId("pubsubReset_Btn").attr('disabled', true);
-                               notify_info("Subscription reset.");
-                       } });
-       }
-
-       return false;
-}
-
-
 function unsubscribeFeed(feed_id, title) {
 
        var msg = __("Unsubscribe from %s?").replace("%s", title);
diff --git a/lib/pubsubhubbub/Publisher.php b/lib/pubsubhubbub/Publisher.php
deleted file mode 100644 (file)
index df7c192..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-/**
- * a PHP client library for pubsubhubbub.
- *
- * @link    https://github.com/pubsubhubbub/
- *
- * @author  Josh Fraser | joshfraser.com | josh@eventvue.com
- * @license Apache License 2.0
- */
-namespace pubsubhubbub\publisher;
-
-use InvalidArgumentException;
-
-class Publisher
-{
-    /**
-     * @var string
-     */
-    protected $hub_url;
-
-    /**
-     * @var string
-     */
-    protected $last_response;
-
-    /**
-     * Create a new Publisher.
-     *
-     * @param string $hub_url
-     */
-    public function __construct($hub_url)
-    {
-        if (! isset($hub_url)) {
-            throw new InvalidArgumentException('Please specify a hub url');
-        }
-
-        if (! preg_match('|^https?://|i', $hub_url)) {
-            throw new InvalidArgumentException('The specified hub url does not appear to be valid: ' . $hub_url);
-        }
-
-        $this->hub_url = $hub_url;
-    }
-
-    /**
-     * Accepts either a single url or an array of urls.
-     *
-     * @param string|array $topic_urls
-     * @param callable     $http_function
-     *
-     * @return mixed
-     */
-    public function publish_update($topic_urls, $http_function = false)
-    {
-        if (! isset($topic_urls)) {
-            throw new InvalidArgumentException('Please specify a topic url');
-        }
-
-        // check that we're working with an array
-        if (! is_array($topic_urls)) {
-            $topic_urls = [$topic_urls];
-        }
-
-        // set the mode to publish
-        $post_string = 'hub.mode=publish';
-        // loop through each topic url
-        foreach ($topic_urls as $topic_url) {
-
-            // lightweight check that we're actually working w/ a valid url
-            if (! preg_match('|^https?://|i', $topic_url)) {
-                throw new InvalidArgumentException('The specified topic url does not appear to be valid: ' . $topic_url);
-            }
-
-            // append the topic url parameters
-            $post_string .= '&hub.url=' . urlencode($topic_url);
-        }
-
-        // make the http post request and return true/false
-        // easy to over-write to use your own http function
-        if ($http_function) {
-            return $http_function($this->hub_url, $post_string);
-        }
-
-        return $this->http_post($this->hub_url, $post_string);
-    }
-
-    /**
-     * Returns any error message from the latest request.
-     *
-     * @return string
-     */
-    public function last_response()
-    {
-        return $this->last_response;
-    }
-
-    /**
-     * Default http function that uses curl to post to the hub endpoint.
-     *
-     * @param string $url
-     * @param string $post_string
-     *
-     * @return bool
-     */
-    private function http_post($url, $post_string)
-    {
-        // add any additional curl options here
-        $options = [
-            CURLOPT_URL        => $url,
-            CURLOPT_POST       => true,
-            CURLOPT_POSTFIELDS => $post_string,
-            CURLOPT_USERAGENT  => 'PubSubHubbub-Publisher-PHP/1.0',
-        ];
-
-        $ch = curl_init();
-        curl_setopt_array($ch, $options);
-
-        $response = curl_exec($ch);
-        $this->last_response = $response;
-        $info = curl_getinfo($ch);
-
-        curl_close($ch);
-
-        return $info['http_code'] == 204;
-    }
-}
diff --git a/lib/pubsubhubbub/Subscriber.php b/lib/pubsubhubbub/Subscriber.php
deleted file mode 100644 (file)
index 5b980a1..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-<?php
-/**
- * A PHP client library for pubsubhubbub.
- *
- * @link    http://code.google.com/p/pubsubhubbub/
- *
- * @author  Josh Fraser | joshfraser.com | josh@eventvue.com
- * @license Apache License 2.0
- */
-namespace Pubsubhubbub\Subscriber;
-
-use InvalidArgumentException;
-
-class Subscriber
-{
-    /**
-     * Put your google key here.
-     * Required if you want to use the google feed API to lookup RSS feeds.
-     *
-     * @var string
-     */
-    protected $google_key = '';
-
-    /**
-     * @var string
-     */
-    protected $hub_url;
-
-    /**
-     * @var string
-     */
-    protected $callback_url;
-
-    /**
-     * @var string
-     */
-    protected $credentials;
-
-    /**
-     * @var string accepted values are "async" and "sync"
-     */
-    protected $verify = 'async';
-
-    /**
-     * @var string
-     */
-    protected $verify_token;
-
-    /**
-     * @var string
-     */
-    protected $lease_seconds;
-
-    /**
-     * Create a new Subscriber (credentials added for SuperFeedr support).
-     *
-     * @param string $hub_url
-     * @param string $callback_url
-     * @param string $credentials
-     */
-    public function __construct($hub_url, $callback_url, $credentials = false)
-    {
-        if (! isset($hub_url)) {
-            throw new InvalidArgumentException('Please specify a hub url');
-        }
-
-        if (! preg_match('|^https?://|i', $hub_url)) {
-            throw new InvalidArgumentException('The specified hub url does not appear to be valid: ' . $hub_url);
-        }
-
-        if (! isset($callback_url)) {
-            throw new InvalidArgumentException('Please specify a callback');
-        }
-
-        $this->hub_url = $hub_url;
-        $this->callback_url = $callback_url;
-        $this->credentials = $credentials;
-    }
-
-    /**
-     * $use_regexp lets you choose whether to use google AJAX feed api (faster, but cached) or a regexp to read from site.
-     *
-     * @param string   $url
-     * @param callable $http_function
-     *
-     * @return string
-     */
-    public function find_feed($url, $http_function = false)
-    {
-        // using google feed API
-        $url = "http://ajax.googleapis.com/ajax/services/feed/lookup?key={$this->google_key}&v=1.0&q=" . urlencode($url);
-        // fetch the content
-        if ($http_function) {
-            $response = $http_function($url);
-        } else {
-            $response = $this->http($url);
-        }
-
-        $result = json_decode($response, true);
-        $rss_url = $result['responseData']['url'];
-
-        return $rss_url;
-    }
-
-    /**
-     * Subscribe to a topic.
-     *
-     * @param string   $topic_url
-     * @param callable $http_function
-     *
-     * @return mixed
-     */
-    public function subscribe($topic_url, $http_function = false)
-    {
-        return $this->change_subscription('subscribe', $topic_url, $http_function);
-    }
-
-    /**
-     * Unsubscribe from a topic.
-     *
-     * @param string   $topic_url
-     * @param callable $http_function
-     *
-     * @return mixed
-     */
-    public function unsubscribe($topic_url, $http_function = false)
-    {
-        return $this->change_subscription('unsubscribe', $topic_url, $http_function);
-    }
-
-    /**
-     * Helper function since sub/unsub are handled the same way.
-     *
-     * @param string   $mode
-     * @param string   $topic_url
-     * @param callable $http_function
-     *
-     * @return mixed
-     */
-    private function change_subscription($mode, $topic_url, $http_function = false)
-    {
-        if (! isset($topic_url)) {
-            throw new InvalidArgumentException('Please specify a topic url');
-        }
-
-        // lightweight check that we're actually working w/ a valid url
-        if (! preg_match('|^https?://|i', $topic_url)) {
-            throw new InvalidArgumentException('The specified topic url does not appear to be valid: ' . $topic_url);
-        }
-
-        // set the mode subscribe/unsubscribe
-        $post_string = 'hub.mode=' . $mode;
-        $post_string .= '&hub.callback=' . urlencode($this->callback_url);
-        $post_string .= '&hub.verify=' . $this->verify;
-        $post_string .= '&hub.verify_token=' . $this->verify_token;
-        $post_string .= '&hub.lease_seconds=' . $this->lease_seconds;
-
-        // append the topic url parameters
-        $post_string .= '&hub.topic=' . urlencode($topic_url);
-
-        // make the http post request and return true/false
-        // easy to over-write to use your own http function
-        if ($http_function) {
-            return call_user_func_array($http_function, [$this->hub_url, $post_string]);
-        }
-
-        return $this->http($this->hub_url, $post_string);
-    }
-
-    /**
-     * Default http function that uses curl to post to the hub endpoint.
-     *
-     * @param string $url
-     * @param string $post_string
-     *
-     * @return mixed
-     */
-    private function http($url, $post_string)
-    {
-
-        // add any additional curl options here
-        $options = [
-            CURLOPT_URL            => $url,
-            CURLOPT_USERAGENT      => 'PubSubHubbub-Subscriber-PHP/1.0',
-            CURLOPT_RETURNTRANSFER => true,
-        ];
-
-        if ($post_string) {
-            $options[CURLOPT_POST] = true;
-            $options[CURLOPT_POSTFIELDS] = $post_string;
-        }
-
-        if ($this->credentials) {
-            $options[CURLOPT_USERPWD] = $this->credentials;
-        }
-
-        $ch = curl_init();
-        curl_setopt_array($ch, $options);
-
-        $response = curl_exec($ch);
-        $info = curl_getinfo($ch);
-
-        // all good -- anything in the 200 range
-        if (substr($info['http_code'], 0, 1) == '2') {
-            return $response;
-        }
-
-        return false;
-    }
-}