Hi!

That´s because you use rawurlencode on the json-string before sending it. 
This is only needed for GET-resquests


Timo

--- Christian <[email protected]> schrieb am Di, 16.3.2010:

Von: Christian <[email protected]>
Betreff: [APE Project] Inline-push with method POST
An: "APE Project" <[email protected]>
Datum: Dienstag, 16. März, 2010 17:20 Uhr

Hello,

if tryed to build an inline push with method post. I thought the ape-
server can handle that. But every time i send it the servers answer
is:

[{"time":"1268756020","raw":"ERR","data":
{"code":"005","value":"BAD_JSON"}}]

Thank you

$APEserver = 'http://my.domain.com:80/?';
$APEPassword = 'testpasswd';

$messages = array(
    'Test Message1',
    'Test Message2',
    'Test Message3',
);

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

$send_Data_json = json_encode($cmd);
$send_Data_json_urlencoded = rawurlencode($send_Data_json);

//$data = file_get_contents($APEserver.$send_Data_json_urlencoded);
//$data = file_post_contents($APEserver.$send_Data_json_urlencoded);
$data = post_curl($APEserver,$send_Data_json_urlencoded);

$json = json_decode($data);

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


function post_curl($url,$postdata) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    $retdata = curl_exec($ch);
    curl_close($ch);
    return $retdata;
}

-- 
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/


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen 
Massenmails. 
http://mail.yahoo.com 

-- 
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