PHP Client Library for APE Ajax Push Engine
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
README.markdown

README.markdown

APE_PHP

Lightweight PHP Client Library to Connect to an APE (APE Ajax Push Engine) server. Fully unit tested with PHPUnit.

API

see: http://tidal.github.com/APE_PHP/docs/api/annotated.html

USAGE

This example is meant to be used as a replacement for the PHP code found in the APE_JSF Controller demo.

<?php

$APEhost = 'localhost';
$APEport = 6969;
$APEPassword = 'testpasswd';

$params =  array( 
   'password'  => $APEPassword, 
   'raw'       => 'postmsg', 
   'channel'   => 'testchannel', 
   'data'      => array( 
      'message' => 'Hello APE' 
   ) 
);

if(ApeFileConnection::available()){
   $conCls = 'ApeFileConnection';
}elseif(ApeCurlConnection::available()){
   $conCls = 'ApeCurlConnection';
}else{
   die('No valid Ape-Connection availabe'); 
}

$connection = new $conCls($APEhost, $APEport);
$client = new ApeClient($connection);
$request = new ApeRequest('inlinepush', $params);
$response = $client->sendRequest($request);
$res = $response->getResult();
if ($res->data->value == 'ok') {
   echo 'Message sent !<pre>'.print_r($res, 1).'</pre>';}
else {
   echo 'Error sending message, server response is : <pre>'.print_r($res, 1).'</pre>';
}
?>

Other approach using ApeClient as a request gateway

<?php
$connection = new $conCls($APEhost, $APEport);
$client = new ApeClient($connection);
$response = $client->dispatchRequest('inlinepush', $params);
if ($response->getResult()->data->value == 'ok') {
   echo 'Message sent !<pre>'.print_r($response->getResult(), 1).'</pre>';}
else {
   echo 'Error sending message, server response is : <pre>'.print_r($response->getResult(), 1).'</pre>';
}
?>