Giter Site home page Giter Site logo

bsahbi / phubb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cweiske/phubb

0.0 0.0 0.0 80 KB

PHP WebSub server. Mirror of http://git.cweiske.de/phubb.git/

License: GNU Affero General Public License v3.0

Shell 0.24% PHP 93.19% TSQL 6.57%

phubb's Introduction

phubb - PHP WebSub server

A WebSub server written in PHP, ready to be run on your own server.

Use it to instantly notify subscribers about updates on your blog's feed, your website's HTML pages or any other HTTP-accessible resources.

Work in progress. Basic functionality is working.

WebSub was formerly called PubSubHubbub.

  • Subscribing to a topic
  • Notifying the hub about a topic update
    • Wildcard URLs supported (with *). All matching subscribed topics are then checked if they changed and notifications are sent out. Wildcards in domain or scheme are not allowed.
  • Sending notifications to subscribers
    • As many worker-processes as you want to speed it up
    • Notifications get only sent when lease time is >= NOW()
    • Notifications get only sent when the content changed. phubb uses etag, last modified and a hash on the content to check that.
  • Re-pinging a subscriber when it failed (exponential back-off)
  • Logging
  • Re-connecting to DB if we had a timeout
  • Subscriber count image (counter.php?topic=$url)
  • PHP
  • PDO
  • PHP Gearman extension
  • Gearman job server, gearman-job-server
  • Monolog
  1. Point the web server's document root to the www/ directory.

  2. Create a new MySQL database and import the schema from data/schema.sql. Database host and username/password/db name can be adjusted by copying data/phubb.config.php.dist to data/phubb.config.php and adjusting it to your needs.

  3. Install dependencies:

    $ composer install
    
  4. Run the worker process bin/phubb-worker.php

  5. Let bin/phubb-cron.php be run by cron every minute.

The hub URL is at http://$domain/hub.php.

When using systemd, you can let it run multiple worker instances when the system boots up:

  1. Copy files data/systemd/phubb*.service into /etc/systemd/system/

  2. Adjust user and group names

  3. Enable three worker processes:

    $ systemctl daemon-reload
    $ systemctl enable phubb@1
    $ systemctl enable phubb@2
    $ systemctl enable phubb@3
    $ systemctl enable phubb
    $ systemctl start phubb
    
  4. Now three workers are running. Restarting the phubb service also restarts the workers.

Send a POST request with the following data:

hub.mode=publish
hub.url=http://topic-url.example.org/

Example:

$ curl -d hub.mode=publish -d "hub.url=http://blog.example.org/feed"\
    http://phubb.example.org/hub.php

or, to automatically publish all modified URLs in that path:

$ curl -d hub.mode=publish -d "hub.url=http://blog.example.org/*"\
    http://phubb.example.org/hub.php

Tasks can be sent via the test-task.php script to the worker.

Verify a subscription:

$ ./bin/test-task.php verify http://phubb.bogo/client-callback.php http://www.bogo/tagebuch/feed/ subscribe 3600 mysecret

Publish an update:

$ ./bin/test-task.php publish http://www.bogo/tagebuch/feed/

Notify subscriber:

$ ./bin/test-task.php notifysubscriber http://www.bogo/tagebuch/feed/ 1 55140a8d865a9
  • stats
  • require domain registration before being able to publish
    • check if URL topic URL has hub link (and self link)
  • do not allow subscriptions for urls that are not registered
  • custom user agent when fetching URLs

phubb's source code is available from http://git.cweiske.de/phubb.git or the mirror on github.

phubb is licensed under the AGPL v3 or later.

phubb was written by Christian Weiske.

phubb's People

Contributors

cweiske avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.