Webpipe.php

PHP library for interacting with Webpipes.

Introduction

Webpipes are tiny HTTP programs that do one thing and do it well. They fill in the gaps. Need a proxy? Need to convert Markdown to HTML? Give a Webpipe some input, and it'll give you some output. They're a handy tool to have in your arsenal.

Think of Webpipes as extending your standard library over HTTP. If you're missing a library in your language of choice, there could be webpipe available instead.

Webpipe.php interacts with webpipes.org, a centralized Webpipe registry and dispatching service.

Learn more at Webpipes.org →

Setup

Add webpipe.class.php to your project folder and don't forget to require().

require('webpipe.class.php);

View code on GitHub →

Usage Example

Webpipe.php exposes two methods: $webpipe->manual() and $webpipe->request().

$webpipe->request()

The real workhorse is $webpipe->request(). This allows you to make requests to any webpipe in registry.webpipes.org.

In this example, let's send a request to the 'proxy' webpipe to fetch my README.markdown for this project from github.

<?php 
// Init 
$webpipe = new Webpipe();

// Make our webpipe request
$response = $webpipe->request("proxy", array(
   "method" => "GET",
   "url" => "https://raw.github.com/matthewhudson/webpipe.php/master/README.markdown"
));

// Print the webpipe response
if ($response) {
   print "<pre>" . $response . "</pre>";
} else {
   print "<pre>Error</pre>";
}
?>

Results in the following output:



	

$webpipe->manual()

This is a convenience function that returns the webpipe.json for the webpipe in question.

<?php
// Init 
$webpipe = new Webpipe();

// Request the 'proxy' webpipe manual (webpipe.json)
$response = $webpipe->manual('proxy');

// Print the webpipe response
if ($response) {
print "<pre>" . $response . "</pre>";
} else {
print "<pre>Error</pre>";
}
?>

Results in the following output:




			

View code on GitHub →