My project is PHP-based and I'm planning to integrate APE with some
realtime updates. I had it working already, but I want to use JQuery
for further development. From this blog is where i was basing my
developments http://bit.ly/kpm17k but I'm having problems applying it
with the existing Demos at APE_JSF\Demos\Controller. Here's my current
code:

For the demo.html (formatted version http://pastebin.com/8GDHKaSx):
    // create our new shiney APE client
    var client = new APE.Client;

    // set to false to disable debugging
    var debug = true;

    // load the APE client
    client.load({
        'domain': APE.Config.domain,
        'server': APE.Config.server,
        'identifier': 'action',
        'channel': 'testchannel',
        'complete': function(ape){
            // APE has finished loading so now we can load our
scripts

            new ape_script(ape).initialize();
        },
        'scripts': APE.Config.scripts //Scripts to load for APE JSF
    });

For the demo.js (formatted version http://pastebin.com/uMS1Zt9m):
function ape_script(ape){
        this.initialize = function(){
                // and when we recieve data
                ape.onRaw('data', this.rawData);

                // start the session with a random name!
                ape.start(String((new Date()).getTime()).replace(/\D/gi,''));
        }

        this.rawData = function(raw, pipe){
                $("div#apeControllerDemo").append(raw.datas.msg);
        }
}

For the Inline PHP (formatted version http://pastebin.com/fnJR6uaB)
<?php
$APEserver = 'http://ape.istoryahi.me:6969/?';
$APEPassword = 'testpasswd';

$messages = array(
        'Test Message',
        '<span style="color: #800">I\'m awesome!</span>',
        '<span style="color: #080">Hey, how are you doing?</span>',
);

$cmd = array(array(
  'cmd' => 'inlinepush',
  'params' =>  array(
          'password'  => $APEPassword,
          'raw'       => 'postmsg',
          'channel'   => 'testchannel',
          'data'      => array( //Note: data can't be a string
              'message' => $messages[array_rand($messages)] ,
                                'information' => 'tralala'
          )
   )
));

var_dump($APEserver.rawurlencode(json_encode($cmd)));
$data =
file_get_contents($APEserver.rawurlencode(json_encode($cmd)));
$data = json_decode($data);

if ($data[0]->data->value == 'ok') {
        echo 'Message sent!';
} else {
        echo 'Error sending message, server response is : <pre>'.$data.'</
pre>';
}

All i keep getting is an error:
[{"time":"1304492295","raw":"ERR","data":
{"code":"001","value":"BAD_PARAMS"}}]

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to