Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.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
Iphone PHP网页生成的返回字符串_Iphone_Ios_Objective C - Fatal编程技术网

Iphone PHP网页生成的返回字符串

Iphone PHP网页生成的返回字符串,iphone,ios,objective-c,Iphone,Ios,Objective C,我的url如下所示: 根据访问令牌是否有效,返回1或“无效”。然而,当我试图返回该值时,我最终返回的是HTML而不是字符串 这就是我目前正在尝试的: - (NSString *) getDataFrom:(NSString *)url{ NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setHTTPMethod:@"GET"]; [request setURL:[N

我的url如下所示:

根据访问令牌是否有效,返回1或“无效”。然而,当我试图返回该值时,我最终返回的是HTML而不是字符串

这就是我目前正在尝试的:

- (NSString *) getDataFrom:(NSString *)url{

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setHTTPMethod:@"GET"];
    [request setURL:[NSURL URLWithString:url]];

    NSError *error = [[NSError alloc] init];
    NSHTTPURLResponse *responseCode = nil;

    NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseCode error:&error];

    if([responseCode statusCode] != 200){
        NSLog(@"Error getting %@, HTTP status code %i", url, [responseCode statusCode]);
        return nil;
    }

    return [[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding];
}

有人能解释一下我是如何返回“1”或“invalidate”的吗?

您给出的url作为示例“”,返回的html带有一个以“”为源的框架:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
 <title>www.sonect.co.uk</title>

</head>
<frameset rows="100%,*" border="0">
  <frame src="http://lvps92-60-123-84.vps.webfusion.co.uk/Requests.php?accessToken=01XJSK"  frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>

<!-- pageok -->
<!-- 02 -->
<!-- -->
</html>

www.sonect.co.uk

该源将返回
1
作为响应。

您给出的url作为示例“”,返回带有一个以“”作为其源的框架的html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
 <title>www.sonect.co.uk</title>

</head>
<frameset rows="100%,*" border="0">
  <frame src="http://lvps92-60-123-84.vps.webfusion.co.uk/Requests.php?accessToken=01XJSK"  frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>

<!-- pageok -->
<!-- 02 -->
<!-- -->
</html>

www.sonect.co.uk

该源将返回
1
作为响应。

您将返回iFrame源,其中包含

http://lvps92-60-123-84.vps.webfusion.co.uk/Requests.php?accessToken=01XJSK

您必须调用此URL,您将得到响应

在浏览器中,由于正在执行iFrame,因此会执行此运行


希望这对您有所帮助。

我们将返回您的iFrame源代码

http://lvps92-60-123-84.vps.webfusion.co.uk/Requests.php?accessToken=01XJSK

您必须调用此URL,您将得到响应

在浏览器中,由于正在执行iFrame,因此会执行此运行


希望这有帮助。

也许将php结果的内容类型设置为text/plain会有帮助:header(“内容类型:text/plain”);这不应该用
PHP
标记,因为网页返回html字符串。将php结果的内容类型设置为text/plain可能会有帮助:header(“content-type:text/plain”);这不应该用
PHP
标记,因为网页返回html字符串。而是返回纯文本。