Home > Backend Development > PHP Tutorial > AFNetworking post到后端,数据怎么调用

AFNetworking post到后端,数据怎么调用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:12:31
Original
1573 people have browsed it

<code> let afn = AFHTTPRequestOperationManager()
     
        afn.POST("http://api.abc.com//index.php?s=/home/order/makeorder.html",parameters:
            ["data":"22222"], success: { (operation: AFHTTPRequestOperation!,
            responseObject: AnyObject!) in
            print("%@", operation.request.allHTTPHeaderFields);
            let data = responseObject as! NSDictionary!
            print("获取数据==%@",data)
            if data != nil {
                //   let dict: NSDictionary = (try! NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)) as! NSDictionary
              //  let modelTool = DictModelManager.sharedManager
              //  let data = modelTool.objectWithDictionary(data, cls: FreshHot.self) as? FreshHot
                
               // completion(data: data, error: nil)
            }
            },
                failure: { (operation: AFHTTPRequestOperation!,
                    error: NSError!) in
                    //Handle Error
                    print("获取数据出错=%@",error);
        })
</code>
Copy after login
Copy after login

后台用php 拿到的$_POST 数据为

<code>a:1:{s:4:"data";s:5:"22222";}</code>
Copy after login
Copy after login

试着对$_Post unserialize,可是得不到数据,,

file_get_contents('php://input') 得到的的数据是

<code>s:10:"data=22222";</code>
Copy after login
Copy after login

请问PHP 改怎么处理AFNetworking post过来的数据?

回复内容:

<code> let afn = AFHTTPRequestOperationManager()
     
        afn.POST("http://api.abc.com//index.php?s=/home/order/makeorder.html",parameters:
            ["data":"22222"], success: { (operation: AFHTTPRequestOperation!,
            responseObject: AnyObject!) in
            print("%@", operation.request.allHTTPHeaderFields);
            let data = responseObject as! NSDictionary!
            print("获取数据==%@",data)
            if data != nil {
                //   let dict: NSDictionary = (try! NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)) as! NSDictionary
              //  let modelTool = DictModelManager.sharedManager
              //  let data = modelTool.objectWithDictionary(data, cls: FreshHot.self) as? FreshHot
                
               // completion(data: data, error: nil)
            }
            },
                failure: { (operation: AFHTTPRequestOperation!,
                    error: NSError!) in
                    //Handle Error
                    print("获取数据出错=%@",error);
        })
</code>
Copy after login
Copy after login

后台用php 拿到的$_POST 数据为

<code>a:1:{s:4:"data";s:5:"22222";}</code>
Copy after login
Copy after login

试着对$_Post unserialize,可是得不到数据,,

file_get_contents('php://input') 得到的的数据是

<code>s:10:"data=22222";</code>
Copy after login
Copy after login

请问PHP 改怎么处理AFNetworking post过来的数据?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template