gpt4 book ai didi

ios - GCD 没有获取网络内容来获取部署在 Internet 上的字符串

转载 作者:行者123 更新时间:2023-11-29 02:54:00 24 4
gpt4 key购买 nike

我正在开发后台线程模块,以获取网页上显示的当前时间 10-06-2014 16:19:11。执行时,没有获取任何数据。你能告诉我如何创建 inputStream 和读取 web 内容吗?假设 https 链接有效给出的消息是:此服务器的证书无效。您是否仍要连接到服务器?,

下面是我的留言

2014-06-10 16:46:16.292 marker[2724:7707] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9807)
2014-06-10 16:46:16.296 marker[2724:60b] Error = Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.cei-hk.net” which could put your confidential information at risk.

" UserInfo=0x146be370 {NSErrorFailingURLStringKey=https://dc02.cei-hk.net:8081/GetTime.aspx, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,
NSErrorFailingURLKey=https://dc02.csd-hk.net:8081/GetTime.aspx, NSLocalizedDescript`

ion=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.cei-hk.net” which could put your confidential information at risk., NSUnderlyingError=0x14582870 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.csd-hk.net” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x14675820>}`

下面是我的代码

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    dispatch_async(dispatch_get_main_queue(), ^{
NSURL *jsonURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://dc02.csd-hk.net:8081/GetTime.aspx",nil]];
NSError *error = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:jsonURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0 ];

NSData *responsedata = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
NSString* jsonData = [[NSString alloc] initWithData:responsedata encoding:NSUTF8StringEncoding];

// NSString *json = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
if( jsonData.length > 0 )
{
NSLog(@"Text=%@", jsonData);
[ToastView showToastInParentView:self.view withText:jsonData withDuaration:5.0];
}
else
{
NSLog(@"Error = %@", error);
}
});

});

最佳答案

您的网址无法解析,您最好检查两次。

看看this替代服务。

关于ios - GCD 没有获取网络内容来获取部署在 Internet 上的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24136123/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com