ios请求php接口失败,laravel,php_iOS调用Laravel接口返回错误信息,laravel,php,ios - phpStudy...

iOS调用Laravel接口返回错误信息

iOS端代码如下:

AFHTTPRequestOperationManager *manage = [[AFHTTPRequestOperationManager alloc]initWithBaseURL:[NSURL URLWithString:@"http://localhost:8000/login/signin"]];

manage.requestSerializer = [AFJSONRequestSerializer serializer];

manage.responseSerializer = [AFJSONResponseSerializer serializer];

[manage.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];

manage.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/plain", @"text/javascript", @"text/json", @"text/html", nil];

[manage POST:@"login/signin" parameters:[self.myLogin toParams] success:^(AFHTTPRequestOperation *operation, id responseObject) {

DebugLog(@"\n===========response===========\n%@:\n%@", @"login/signin", responseObject);

[_activityIndicator stopAnimating];

_loginButton.enabled = YES;

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

DebugLog(@"\n===========response===========\n%@:\n%@", @"login/signin", error);

[_activityIndicator stopAnimating];

_loginButton.enabled = YES;

}];

Laravel的代码如下:

routes.php

----------

Route::post('login/signin',[

'as'=>'signin','uses'=>'Login\LoginController@signin'

]);

LoginController.php

----------

public function signin()

{

$message = "登录成功";

$data = array('phone'=>'13800138000','password'=>'123456');

$code = 0;

return response()->json(['message'=>$message,'data'=>$data,'code'=>0]);

}

提示错误:Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x7fe00d90a3a0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

但是将Route::post 改成 Route::get

manage POST:@"login/signin" 改成 manage GET:@"login/signin"

可以返回数据如下:

{

code = 0;

data = {

password = 123456;

phone = 13800138000;

};

message = "\U767b\U5f55\U6210\U529f";

}

请问问题出在哪里,求帮助,谢谢各位:D 。

使用Paw查看POST数据会出现php错误如下:

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is

deprecated and will be removed in a future version. To avoid this

warning set 'always_populate_raw_post_data' to '-1' in php.ini and

use the php://input stream instead. in Unknown on line 0

Warning: Cannot modify header information

- headers already sent in Unknown on line 0

相关阅读:

如何判断浏览器上传文件的真实类型?

Call to undefined function dns_get_record()

PHPrpc远程调用,但是每个方法的参数个数不一致,不想写死,怎么搞?

求助,像这种外卖订单怎么在页面里点击按钮实现呢?跪求!

帮忙看下,返回顶部什么问题?

谁有vim里CSS的Indent文件, 能缩进@media里面的

iOS:UIScrollView手动拖拽后如何判断是否滚动到别的页面?

求解关于display:table的问题

怎么将文件改名为大写?

负载均衡问题啊

为什么React中this.state不要直接修改,而是创建新的副本?

mongodb aggregate 找不到运算符

iOS 6S Plus 界面 显示不全 出现图片丢失

社区没有搞单片机的?

Centos7 如何查看谁使用了内存?ps -aux | sort -k4nr是什么

完全自定义auth模块需要做什么?

golang &0xffff作用

Ajax如何调用python脚本

网站前端和服务器端ajax交互的时候什么时候该选POST,什么时候该选GET?

为什么现在的web项目的字符集都要求是UTF-8?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值