我正在尝试调用http和https并尝试解析响应。我正在收到 http 呼叫的响应,但对于 https 呼叫,我收到此错误
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error
void MyClass::on_push_button_clicked()
{
QString address = "New York";
QNetworkAccessManager *qnam__get_address=NULL;
QNetworkRequest request;
QString myurl;
//myurl = "http://google.com/complete/search?output=toolbar&q="+address;
myurl = "https://maps.googleapis.com/maps/api/geocode/xml?address=New York&key=google api key";
QUrl url(myurl);
request.setUrl(url);
qDebug() << url;
qnam__get_address = new QNetworkAccessManager(this);
if(qnam__get_address) {
QObject::connect(qnam__get_address, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(onSslError(QNetworkReply*, QList<QSslError>)));
QObject::connect(qnam__get_address, SIGNAL(finished(QNetworkReply*)),this, SLOT(on_push_button_clicked_response(QNetworkReply*)));
reply = qnam__get_address->get(request);
}
return;
}
void MyClass::onSslError(QNetworkReply* r, QList<QSslError> errors)
{
r->ignoreSslErrors();
}
void MyClass::on_push_button_clicked_response(QNetworkReply* reply)
{
// no error received?
if (reply->error() == QNetworkReply::NoError)
{
qDebug()<<"MyClass:: got the response";
}
// Some http error received
else
{
qDebug() << ".......error";
}
if(reply)
{
reply->deleteLater();
}
return;
}
有人可以告诉我如何解决此错误吗?我到底需要做什么?
我观察到的一个奇怪的行为是,当我将 libeay32.dll 和 ssleay32.dll 文件与.exe文件一起保存时,我得到了 https 的响应,但没有得到 http 响应。
愚蠢的高度......我安装了OpenSSL,它解决了这个问题。所以现在如果我尝试运行/调试它,我不会收到任何错误。
我发现了为什么这些 URL 不起作用。myurl = "http://google.com:80/complete/search?output=toolbar&q="+地址;myurl = "https://maps.googleapis.com:443/maps/api/geocode/xml?address=New York&key=Google API key";添加端口后,我得到了响应。