X.Commerce message handling extension for PHP5
C Shell PHP
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples Add support for more primitive types, discriminate types, and examples May 19, 2012
.gitignore
.gitmodules
INSTALL
LICENSE Added INSTALL and LICENSE files May 20, 2012
README.md update README Sep 25, 2012
config.m4 Escape # with a quadrigraph Aug 20, 2012
config.w32 Windows build Sep 7, 2012
debian.control Debian/ubuntu build files Jul 12, 2012
mkdeb-apache2.sh
package.xml Prep for 1.0.5 Dec 17, 2012
php_xcom.h Windows build fix, remove trailing slashes Sep 17, 2012
xcom.c Handle non-array hdrs param Dec 17, 2012

README.md

php5-xcom

X.commerce message handling extension for PHP5 (www.x.com)

Installing/Configuring

Debian pkg's are provided under debs/

$ phpize && ./configure
$ make && sudo make install
# echo "extension=xcom.so" >> /your/php.ini

A gcc-like toolchain, php headers, and libavro (installation instructions below) are required.

Pre-compiled Windows binaries can be found @ https://github.com/johnj/php5-xcom/downloads

Examples

Sending a message to X.commerce:

<?php

$data = new stdClass();
$data->member_id = 123495585343;

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

var_dump($xcom->send("/topic/", $data, '{"json": "schema"}'));

/*
 * Output:
 * int(200)
 */

?>

Receiving a message from X.commerce:

<?php

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

var_dump($xcom->decode(file_get_contents("php://input"), '{"json": "schema"}'));

/*
 * Output:
 * object(stdClass)#87 (2) { ["username"]=> string(2) "hi" ["active"]=> int(38347473) }
 */
?>

Debugging:

<?php

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

$xcom->__debug = true;

$xcom->send($topic, $data, '{"json": "schema"}');
var_dump($xcom->getDebugOutput());

?>

Encoding a message:

<?php

$data = new stdClass();
$data->member_id = 123495585343;

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

var_dump($xcom->encode($data, '{"json": "schema"}'));

/*
 * Output:
 * a binary string that contains an avro message, which can be POST'ed to
 * X.Commerce
 */

?>

libavro

In order to compile the xcommerce extension you will need libavro.

The libavro build uses CMake (available in most package managers).

$ git clone https://github.com/johnj/avro.git
$ cd avro/lang/c
$ cmake .
$ sudo make install

SSL Certificates

If you run into issues with SSL negotiation, you can try to get the CA certs available @ http://curl.haxx.se/docs/caextract.html