我用最简单的调用方法:var
  Param:TStringList; URL: String;
  RStream:TStringStream;
begin
  Param:=TStringList.Create;
  RStream:=TStringStream.Create('');
  URL := 'https://gw.open.1688.com/openapi/http/1/system.oauth2/getToken/'+edtAppKey.Text+'?';
  Param.Add('grant_type=authorization_code');
  Param.Add('need_refresh_token=true');
  Param.Add('client_id='+edtAppKey.Text);
  Param.Add('client_secret='+edtAppSecret.Text);
  Param.Add('redirect_uri=http://gw.open.1688.com/auth/authCode.htm');
  Param.Add('code='+edtCode.Text);
  IdHTTP1.Post(URL,Param,RStream);
  memInfo.Text := RStream.DataString; 执行后,在post时提示: IOHandler value is not valid。 我现在调用阿里巴巴的1688接口,阿里的客服不能解决这个问题,我用IdHTTP1.Get,在淘宝API接口调用全是正常的。Delphi IdHttpPostDelphiIdHttpPost

解决方案 »

  1.   

    我同时备注下之前描述的,使用code获取令牌 https://gw.open.1688.com/openapi/http/1/system.oauth2/getToken/YOUR_APPKEY?grant_type=authorization_code&need_refresh_token=true&client_id= YOUR_APPKEY &client_secret= YOUR_APPSECRET &redirect_uri=YOUR_REDIRECT_URI&code=CODE
    注:此接口必须使用POST方法提交;必须使用https
    getToken接口参数说明:
    a) grant_type为授权类型,使用authorization_code即可
    b) need_refresh_token为是否需要返回refresh_token,如果返回了refresh_token,原来获取的refresh_token也不会失效,除非超过半年有效期
    c) client_id为app唯一标识,即appKey
    d) client_secret为app密钥
    e) redirect_uri为app入口地址
    f) code为授权完成后返回的一次性令牌
      

  2.   

    我换成IEHTTP控件就正常了 我吐血,INDY控件有这么差么?
      

  3.   

      IEHTTP1.RequestMethod := 'POST';
      IEHTTP1.ExecuteURL(URL);
      memInfo.Text := IEHTTP1.result_sl.Text;
      

  4.   

    fullhappy 老哥,你好,你有没有QQ可以加一下你啊,我们也在研究这一块