Tuesday, July 30, 2013

CURL post fields and empty data

Hi everybody. I'm getting crazy with a very small webservice. From client side I'm making a POST request with cURL, sending a post field called userid.
Something like:
CURLOPT_POSTFIELDS => array('loginid' => 'MyLoginData123').
On the server side, $this->request->data is empty since the request is not coming from a cakephp form. $_POST is also empty, maby cleared by cakephp.
The previous solution (valid in older versions of cakephp) to access external from data with $this->params['form'] isn't valid anymore.
Doing a debug($this->request) i get this:
object(CakeRequest) {
params => array(
'plugin' => null,
'controller' => 'links',
'action' => 'getclientlinks',
'named' => array(),
'pass' => array(),
'isAjax' => false
)
data => array()
query => array()
url => 'links/getclientlinks'
base => ''
webroot => '/'
here => '/links/getclientlinks'
[protected] _detectors => array(
'get' => array(
'env' => 'REQUEST_METHOD',
'value' => 'GET'
),
'post' => array(
'env' => 'REQUEST_METHOD',
'value' => 'POST'
),
'put' => array(
'env' => 'REQUEST_METHOD',
'value' => 'PUT'
),
'delete' => array(
'env' => 'REQUEST_METHOD',
'value' => 'DELETE'
),
'head' => array(
'env' => 'REQUEST_METHOD',
'value' => 'HEAD'
),
'options' => array(
'env' => 'REQUEST_METHOD',
'value' => 'OPTIONS'
),
'ssl' => array(
'env' => 'HTTPS',
'value' => (int) 1
),
'ajax' => array(
'env' => 'HTTP_X_REQUESTED_WITH',
'value' => 'XMLHttpRequest'
),
'flash' => array(
'env' => 'HTTP_USER_AGENT',
'pattern' => '/^(Shockwave|Adobe) Flash/'
),
'mobile' => array(
'env' => 'HTTP_USER_AGENT',
'options' => array(
(int) 0 => 'Android',
(int) 1 => 'AvantGo',
(int) 2 => 'BlackBerry',
(int) 3 => 'DoCoMo',
(int) 4 => 'Fennec',
(int) 5 => 'iPod',
(int) 6 => 'iPhone',
(int) 7 => 'iPad',
(int) 8 => 'J2ME',
(int) 9 => 'MIDP',
(int) 10 => 'NetFront',
(int) 11 => 'Nokia',
(int) 12 => 'Opera Mini',
(int) 13 => 'Opera Mobi',
(int) 14 => 'PalmOS',
(int) 15 => 'PalmSource',
(int) 16 => 'portalmmm',
(int) 17 => 'Plucker',
(int) 18 => 'ReqwirelessWeb',
(int) 19 => 'SonyEricsson',
(int) 20 => 'Symbian',
(int) 21 => 'UP\.Browser',
(int) 22 => 'webOS',
(int) 23 => 'Windows CE',
(int) 24 => 'Windows Phone OS',
(int) 25 => 'Xiino'
)
),
'requested' => array(
'param' => 'requested',
'value' => (int) 1
)
)
[protected] _input => '------------------------------1e37f69d3cc8
Content-Disposition: form-data; name="loginid"

MyLoginData123
------------------------------1e37f69d3cc8
Content-Disposition: form-data; name="userid"

MyUserData12345
------------------------------1e37f69d3cc8--
'
}


As you see I posted 2 fields (loginid and userid), but I can't access them.

Is there a way to access post data not originated by a cakephp form?

Thank you

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: