开发者

WinInet google maps data api receive error Invalid Token

开发者 https://www.devze.com 2022-12-13 19:20 出处:网络
I am trying to login to Google maps data API (get MyMaps) with wininet and delphibut always recevied response: Invalid Token.

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;


Terminate the headers with a linefeed maybe?

0

精彩评论

暂无评论...
验证码 换一张
取 消