CakePHP2.5如何从Android接收数据post?
我想知道CakePHP2.5是如何从Android接收数据post的 我想知道以下几点 1.从Android应用程序发送的URL 2.接收数据的方法是POST(CakePhp) 我试过很多次了,但都做不到 从安卓系统发送数据得到了准确的确认 一, 现在我写了下面的URL。我不知道它是对的 http://***/cake/books/test 二, BooksController.phpCakePHP2.5如何从Android接收数据post?,android,cakephp,post,Android,Cakephp,Post,我想知道CakePHP2.5是如何从Android接收数据post的 我想知道以下几点 1.从Android应用程序发送的URL 2.接收数据的方法是POST(CakePhp) 我试过很多次了,但都做不到 从安卓系统发送数据得到了准确的确认 一, 现在我写了下面的URL。我不知道它是对的 http://***/cake/books/test 二, BooksController.php <?php class BooksController extends AppContr
<?php
class BooksController extends AppController
{
public $name = 'Books';
public $uses = array('Book');
public function test()
{
$add = "";
if( isset($this->request->data['id']))
{
$add = $this->request->data['id'];
$this->set( 'address' , $add);
}
}
}
?>
test.ctp
<div>
<?php
if( isset($address) )
{
pr($address);
}
?>
</div>
在CakePHP中,您可以使用以下函数测试它是否是POST请求:
if($this->request->is('post')) {
...
}
根据Web服务器和CakePHP的设置,发布的URL也可以是:
http://*/books/test(不含蛋糕部分)只要命令Android发布一个URL示例即可 www.sample.com/controller\u name/function\u name/123 ,123是您的代码或变量 然后可以将其用作简单的函数参数
//in your controller
function register($uuid=null)
{
echo $uuid; //$uuid is value post by android, register() is function name
}
那么,怎么了?提格朗,谢谢你!!没有错误。Android和CakePHP都有。谢谢。问题已经解决了。最初的目的是将一个变量放入数据库。然后我可以用你的建议代码来做。我不知道为什么不能回显从Android接收到的值。Wayne Tun,谢谢,问题已经解决了。最初的目的是将一个变量放入数据库。那我就可以做了。但我不能用你的建议代码。我不知道为什么不能回显从Android接收到的值。