Re: How to get the content of a 'custom' POST-Request

2007-05-15 Thread Marcus T. Jaschen

[EMAIL PROTECTED] wrote:
 Perhaps you should try:
 $post_data = file_get_contents ('php://input');
 
 That will tell you if your data is being posted correctly.

Ok, I tried that and ... it shows me the POST-Data as one would expect
it. My POST-Request:

POST /games/send_data HTTP/1.1
Host: tk.loc
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.3)
Gecko/20070309 Firefox/2.0.0.3
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Cookie:
tkAuth=%BD%1C%BDl%BB%C4%FE%A8e%8D%1D%86%0F%C4%7E%0C%82%D4%D7%A5%8FE%C2%8F+%8E%E5%F2Y%3B%87%9B+zK%FF%034%5E%09Z%5B%F7%23%92S%D7%B5%AC%9D%16t%C8K%1F%0E%D3h%D9%3A%B4%91%08%0B%3C%93DquS%80%0D%CD%8C%A5%A7%AC%C6%80%FC%FF%81B%E9%A0%E38%99%DCs%A2%CC%D7%5D%A4%D5;
tkSession=332e7a6effc76b9bac3c0ed985e0bde5
Referer: http://tk.loc/swf/games/urlRequest.swf
Content-type: text/xml
Content-length: 80

gameinfo
  game
id1/id
score2000/score
  /game
/gameinfo

When I dump the $_POST variable I get an empty Array:

pre class=cake_debug
Array
(
)
/pre

When I dump the data with php://input I get the assumed data:

pre class=cake_debug
gameinfo
  game
id1/id
score2000/score
  /game
/gameinfo
/pre

After reading the PHP manual I think I'll use the php://input stream for
working with my POST data - it seems to be a good choice. $_POST seems
to hold only POST variables but not POST raw data - it seems that this
is the reason why I cannot access my XML snippet within the $_POST
variable ...

Chris and the unknown Gmane-Poster - thanks for your help :)

Marcus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread Chris Hartjes

On 5/14/07, Marcus [EMAIL PROTECTED] wrote:

 Hello guys,

 I'm trying to get the plain data from a POST (not a submitted form!)
 request. Think about such a request:

 POST /baz/post_test HTTP/1.1
 Host: foobar.baz
 Content-Type: text/xml
 Content-Length: 666

 abc
   def123/def
 /abc

 How can I access the POST body (the part starting with abc ...) in
 CakePHP?

 I can't see anything of the POST body if I dump the Controller's data
 with debug($this)

 Marcus

Looks like it's returning XML, so you need to parse the response using
whatever XML tools are available:  SimpleXML in PHP 5 is what I always
use, not familiar with all the choices in PHP 4.

Hope that helps.

-- 
Chris Hartjes

My motto for 2007:  Just build it, damnit!

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread Marcus

Yes, I want to parse it with SimpleXML. But to do this I need to
access this data from within CakePHP - and this is my problem: I can't
access the POST body (XML snippet) in my controller action ...

(in this case we have a XML snippet in the POST request but it's also
possible that we have plain text here)

Marcus

On 14 Mai, 20:11, Chris Hartjes [EMAIL PROTECTED] wrote:
 On 5/14/07, Marcus [EMAIL PROTECTED] wrote:





  Hello guys,

  I'm trying to get the plain data from a POST (not a submitted form!)
  request. Think about such a request:

  POST /baz/post_test HTTP/1.1
  Host: foobar.baz
  Content-Type: text/xml
  Content-Length: 666

  abc
def123/def
  /abc

  How can I access the POST body (the part starting with abc ...) in
  CakePHP?

  I can't see anything of the POST body if I dump the Controller's data
  with debug($this)

  Marcus

 Looks like it's returning XML, so you need to parse the response using
 whatever XML tools are available:  SimpleXML in PHP 5 is what I always
 use, not familiar with all the choices in PHP 4.

 Hope that helps.

 --
 Chris Hartjes

 My motto for 2007:  Just build it, damnit!

 @TheBallpark -http://www.littlehart.net/attheballpark
 @TheKeyboard -http://www.littlehart.net/atthekeyboard


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread Chris Hartjes

On 5/14/07, Marcus [EMAIL PROTECTED] wrote:

 Yes, I want to parse it with SimpleXML. But to do this I need to
 access this data from within CakePHP - and this is my problem: I can't
 access the POST body (XML snippet) in my controller action ...

I don't follow you here.  You mean you can't access the $_POST variable at all?

 (in this case we have a XML snippet in the POST request but it's also
 possible that we have plain text here)


Why can't it always be XML in the response?

-- 
Chris Hartjes

My motto for 2007:  Just build it, damnit!

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread Marcus

On May 14, 8:39 pm, Chris Hartjes [EMAIL PROTECTED] wrote:

  Yes, I want to parse it with SimpleXML. But to do this I need to
  access this data from within CakePHP - and this is my problem: I can't
  access the POST body (XML snippet) in my controller action ...

 I don't follow you here.  You mean you can't access the $_POST variable at 
 all?

The $_POST variable is empty if I try to dump it with debug() in my
controller ...

  (in this case we have a XML snippet in the POST request but it's also
  possible that we have plain text here)

 Why can't it always be XML in the response?

I don't mean the response - I mean the request but this isn't
important now ;)

thanks, Marcus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread Chris Hartjes

On 5/14/07, Marcus [EMAIL PROTECTED] wrote:
 
  I don't follow you here.  You mean you can't access the $_POST variable at 
  all?

 The $_POST variable is empty if I try to dump it with debug() in my
 controller ...

Okay, I'm even more confused now (but that's common these days).

I'm assuming you have an action that you are sending your POST request
to, correct?


-- 
Chris Hartjes

My motto for 2007:  Just build it, damnit!

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread Marcus

On May 14, 9:11 pm, Chris Hartjes [EMAIL PROTECTED] wrote:

   I don't follow you here.  You mean you can't access the $_POST variable 
   at all?

  The $_POST variable is empty if I try to dump it with debug() in my
  controller ...

 Okay, I'm even more confused now (but that's common these days).

 I'm assuming you have an action that you are sending your POST request
 to, correct?

I've a Flash file (SWF) which calls an action in my Cake application
with a POST request and sends some XML in the POST body. I debugged it
on the protocol layer (http; with Firebug and Fiddler) and the POST
request contains the XML as POST body and looks fine.

But if I want to access the $_POST (with 'debug($_POST)' in the called
action - yes this action exists) only an empty array is shown. That
confuses me a little bit ;)

Marcus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to get the content of a 'custom' POST-Request

2007-05-14 Thread [EMAIL PROTECTED]

Perhaps you should try:
$post_data = file_get_contents ('php://input');

That will tell you if your data is being posted correctly.

On May 14, 4:11 pm, Marcus [EMAIL PROTECTED] wrote:
 On May 14, 9:11 pm, Chris Hartjes [EMAIL PROTECTED] wrote:

I don't follow you here.  You mean you can't access the $_POST variable 
at all?

   The $_POST variable is empty if I try to dump it with debug() in my
   controller ...

  Okay, I'm even more confused now (but that's common these days).

  I'm assuming you have an action that you are sending your POST request
  to, correct?

 I've a Flash file (SWF) which calls an action in my Cake application
 with a POST request and sends some XML in the POST body. I debugged it
 on the protocol layer (http; with Firebug and Fiddler) and the POST
 request contains the XML as POST body and looks fine.

 But if I want to access the $_POST (with 'debug($_POST)' in the called
 action - yes this action exists) only an empty array is shown. That
 confuses me a little bit ;)

 Marcus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---