WinInet谷歌地图数据api收到错误无效令牌

时间:2009-12-14 07:55:26

标签: delphi token wininet

我正在尝试使用wininet和delphi登录Google地图数据API(获取MyMaps)但总是收到回复:无效令牌。

我通过wininet HTTPS调用获得了auth toke。
有什么问题 ?

请帮忙。这是一个示例代码:



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;

1 个答案:

答案 0 :(得分:0)

使用换行符终止标题?