Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用url将数据从iphone发送到服务器_Php_Iphone_Xcode_Url_Nsurlconnection - Fatal编程技术网

Php 如何使用url将数据从iphone发送到服务器

Php 如何使用url将数据从iphone发送到服务器,php,iphone,xcode,url,nsurlconnection,Php,Iphone,Xcode,Url,Nsurlconnection,我想知道如何使用url将iphone应用程序中的数据发送到mysql服务器中的表中 其中“@”是xcode中的纬度和经度变量。嗨,朋友 为此,您需要首先使用ASIHttp连接委托设置连接 为此,您需要首先使用HTTP连接委托设置连接。以这种方式与服务器交互的最常见方法是通过stringWithContentsOfURL:encoding:error:方法(以及NSString中的其他相关方法)和能够执行异步后台请求的类 上述两个链接的类参考文档都包含代码示例(请参见每个文档顶部的“相关示例代码

我想知道如何使用url将iphone应用程序中的数据发送到mysql服务器中的表中

其中“@”是xcode中的纬度和经度变量。

嗨,朋友 为此,您需要首先使用ASIHttp连接委托设置连接
为此,您需要首先使用HTTP连接委托设置连接。以这种方式与服务器交互的最常见方法是通过
stringWithContentsOfURL:encoding:error:
方法(以及NSString中的其他相关方法)和能够执行异步后台请求的类

上述两个链接的类参考文档都包含代码示例(请参见每个文档顶部的“相关示例代码”部分)

此外,还有第三方解决方案可用,例如常用类


一旦数据“命中”服务器,在将数据存储到数据库表之前,您将从superglobal中检索数据。有各种各样的方法(使用抽象层,例如,等等),因此这实际上取决于您的个人喜好。

以这种方式与服务器交互的最常见方法是通过
stringWithContentsOfURL:encoding:error:
方法(以及NSString中的其他相关方法)和类,它能够执行异步后台请求

上述两个链接的类参考文档都包含代码示例(请参见每个文档顶部的“相关示例代码”部分)

此外,还有第三方解决方案可用,例如常用类


一旦数据“命中”服务器,在将数据存储到数据库表之前,您将从superglobal中检索数据。有各种各样的方法(使用抽象层,例如,等等),因此这实际上取决于您的个人喜好。

您可以使用以下代码 首先,您可能已经导入了asihttprequest包和所有必需的框架

#import "ASIHTTPRequest.h"
#import "ASINetworkQueue.h"
在viewcontroller.h文件中

ASINetworkQueue  *networkQueue;
在viewController.m文件中:- 在viewdidLoad中:-

networkQueue=[[ASINetworkQueue queue]retain];
在要发送请求的位置编写以下代码:-

NSString *str = [NSString stringWithFormat:@"http://localhost/location.php?id=&latitude=%@&longitude=%@",latitude,longitude];
        NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
        [request setRequestMethod:@"GET"];
        [request setDelegate:self];
        [request setDidFinishSelector: @selector(*writemethodforsuccessfulrequest*)];
        [request setDidFailSelector: @selector(*writemethodforrequestfailed*)];
        [networkQueue addOperation: request];
        [networkQueue go];
在Dealoc中:-

[networkQueue cancelAllOperations];
[networkQueue release]; 

您可以使用以下代码 首先,您可能已经导入了asihttprequest包和所有必需的框架

#import "ASIHTTPRequest.h"
#import "ASINetworkQueue.h"
在viewcontroller.h文件中

ASINetworkQueue  *networkQueue;
在viewController.m文件中:- 在viewdidLoad中:-

networkQueue=[[ASINetworkQueue queue]retain];
在要发送请求的位置编写以下代码:-

NSString *str = [NSString stringWithFormat:@"http://localhost/location.php?id=&latitude=%@&longitude=%@",latitude,longitude];
        NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
        [request setRequestMethod:@"GET"];
        [request setDelegate:self];
        [request setDidFinishSelector: @selector(*writemethodforsuccessfulrequest*)];
        [request setDidFailSelector: @selector(*writemethodforrequestfailed*)];
        [networkQueue addOperation: request];
        [networkQueue go];
在Dealoc中:-

[networkQueue cancelAllOperations];
[networkQueue release]; 
简单的 试试这个

简单的 试试这个

副本的副本