使用来自中国的谷歌地理编码api
using google-geocoding-api from China
我是一名来自中国的新手程序员。我在使用google-geocoding-api时遇到了一些问题,当我用以下代码调试时是正确的,但是当我使用生成的.exe文件在发布模式下编译时没有响应。因为我在中国,所以我只能用网络代理访问URL,所以我不知道是网络问题还是我的代码问题。有人能帮我试试下面的代码来检查到底是什么问题吗?
// street_name.cpp :
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <Windows.h>
#include <wininet.h>
using namespace std;
#define MAXBLOCKSIZE 500
#pragma comment (lib, "wininet.lib")
void download(const char*);
int main(int argc, char* argv[]){
const char *cUrl = NULL;
char Url[512];
float lat = 45.798748;
float lng = 126.531115;
sprintf(Url,"https://maps.googleapis.com/maps/api/geocode/xml?latlng=45.797749,126.523811&result_type=route&address_component_type=route&key=AIzaSyC6M3Pbbjdrgtl8QZjuJPK-1JdAJD5oEgA",lat,lng);
cUrl = Url;
download(cUrl);
if (argc > 1)
{
download((const char*)argv[1]);
}
else
{
cout << "Usage: auto-Update url";
}
return 0;
}
/**
*
* @param Url: The target action url
*
*/
void download(const char *Url)
{
HINTERNET hSession = InternetOpenA("RookIE/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
string StreetName;
if (hSession != NULL)
{
HINTERNET handle2 = InternetOpenUrlA(hSession, Url, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
if (handle2 != NULL)
{
cout << Url << endl;
byte Temp[MAXBLOCKSIZE] = {0};
ULONG Number = 1;
int i = 0;
ofstream ofs("baidu.txt");
if (ofs)
{
while (Number > 0)
{
InternetReadFile(handle2, Temp, MAXBLOCKSIZE - 1, &Number);
string a = string((const char*)Temp,Number);
ofs << a.c_str();
StreetName += a;
}
ofs.close();
}
InternetCloseHandle(handle2);
handle2 = NULL;
}
InternetCloseHandle(hSession);
hSession = NULL;
}
}
如果您的请求来自中国,可能是HTTPS请求被阻止了。试着HTTP .
我想这可能与https://meta.stackexchange.com/questions/191338/https-problem-when-accessing-stack-overflow-in-china有关
相关文章:
- 如何确定我已使用非编码文件到达 EOF?
- 用于访问容器<T>数据成员的正确 API
- 如何使用Luacneneneba API正确读取字符串和表参数
- C++MySQL C api用户输入行
- 如何使用 AWS Transcribe C++ API 中的'StartTranscriptionJobRequest'?
- 将std::string传递给WriteConsole API
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 在卡萨布兰卡形成编码参数的列表
- 在gtest.中使用fff.h模拟系统API
- 有没有任务栏API可以立即应用注册表更改
- C++win32 API创建多个类似视口的窗口
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 如何将真正的字符串从python c-api转换为python脚本
- 使用 NvPipe 编码桌面复制 API ID3D11Texture2D 帧
- Windows API base64编码/解码
- 如何将API名称制成变量以易于编码
- 如何在 Windows API 中指定与编码无关的字符串常量
- 如何使用ffmpegc API对H.264视频进行编码,然后用媒体播放器打开输出
- 使用来自中国的谷歌地理编码api