WinInet 谷歌地图数据 api 接收错误无效令牌
我正在尝试使用 wininet 和 delphi 登录 Google 地图数据 API(获取 MyMaps),但总是收到响应:无效令牌。
我已经通过 wininet HTTPS 调用获得了身份验证令牌。
有什么问题吗?
请帮助。这里是示例代码:
ServerURL='maps.google.com';
pathURL='/maps/feeds/maps/default/full';
headers='Authorization: GoogleLogin auth="jbhi6....7it6g976"'; //or like that
function SendHTTP_GET(const ServerURL, pathURL, headers:string): string;
var
IInternet, Connection, aFile: HINTERNET;
begin
Result:= '';
IInternet := InternetOpen(PChar('MyApp'), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
Connection := InternetConnect(IInternet, pAnsiChar(ServerURL), INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
try
aFile := HttpOpenRequest(Connection,'GET',pAnsiChar(pathURL), nil, nil, nil, 0, 0);
try
if HttpSendRequest(aFile, pAnsiChar(headers), Length(headers), nil, 0) then
Result := ReadStreamData(aFile)
finally
InternetCloseHandle(aFile);
end;
finally
InternetCloseHandle(Connection);
end;
finally
InternetCloseHandle(IInternet);
end;
end;
I am trying to login to Google maps data API (get MyMaps) with wininet and delphi but always recevied response: Invalid Token.
I have gotten auth toke with wininet HTTPS call.
What's the problem ?
Please help.Here a example code :
ServerURL='maps.google.com';
pathURL='/maps/feeds/maps/default/full';
headers='Authorization: GoogleLogin auth="jbhi6....7it6g976"'; //or like that
function SendHTTP_GET(const ServerURL, pathURL, headers:string): string;
var
IInternet, Connection, aFile: HINTERNET;
begin
Result:= '';
IInternet := InternetOpen(PChar('MyApp'), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
Connection := InternetConnect(IInternet, pAnsiChar(ServerURL), INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
try
aFile := HttpOpenRequest(Connection,'GET',pAnsiChar(pathURL), nil, nil, nil, 0, 0);
try
if HttpSendRequest(aFile, pAnsiChar(headers), Length(headers), nil, 0) then
Result := ReadStreamData(aFile)
finally
InternetCloseHandle(aFile);
end;
finally
InternetCloseHandle(Connection);
end;
finally
InternetCloseHandle(IInternet);
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许用换行符终止标题?
Terminate the headers with a linefeed maybe?