XCode7 using HTTPS communication, add an attribute @{@ "nsapptransportsecurity" to the Info.plist file: @{@ "nsallowsarbitraryloads": YES}}
Interface website: http://www.webxml.com.cn
XML International Standard
JSON Popular Standard
get: Easy to use, not safe for exposed interfaces
The interface macro definition of QQ online query get
#define Qqonlineurl_get @ "http://webservice.webxml.com.cn/webservices/qqonlinewebservice.asmx/qqcheckonline?qqcode=%@"
(0) #define Macro name @ ""
(1) Write the interface as a macro definition to note the "/http" prefix
(2) The copy behind the host is connected to (1) behind
(3) After the assignment of Get back to (2), change the string to%@ placeholder
(4) Use String to stitch the macro name, wrap the string into an address using nsurl
(5) Use address to obtain Nsurkrequest request
(6) Asynchronously fetching data using nsurlconnection
Post: Use complex, secure, and multi-method
QQ Online query interface macro definition Post
#define Qqonlineurl_post @ "Http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx/qqCheckOnline"
(0) #define Macro name @ ""
(1) write the interface as a macro definition to note the "/http" prefix
(2) The copy behind the host is connected to (1) behind
(3) Copy the back of post to the back of (2)
(4) Get URL
(5) Use Nsmutableurlrequest to get request from URL
(6) Using the Request class method Sethttpmethod set the request mode to post, default to get
(7) Use a string to get the input content, encapsulated into the data type
(8) using the Request class method Sethttpbody set the requestor data
(9) SetValue "value" Forhttpheaderfield "key" to set the request header using the Request class method
For example: [req setvalue:[nsstring stringwithformat:@ "%ld", Paramdata.length] forhttpheaderfield:@ "Content-length"];
(10) Get data asynchronously using Nsurlconnection
iOS network programming--day4 (using Nsurlconnection to get data asynchronously)