Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

X.Commerce message handling extension for PHP5

tree: e34eac2389

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 INSTALL
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 config.m4
Octocat-spinner-32 debian.control
Octocat-spinner-32 mkdeb-apache2.sh
Octocat-spinner-32 package.xml
Octocat-spinner-32 php_xcom.h
Octocat-spinner-32 xcom.c
README.md

php5-xcom

X.Commerce message handling extension for PHP5

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.

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 (usually available in all 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

Something went wrong with that request. Please try again.