本文整理自网络,侵删。
下面是delphi调用极光推送服务端HTTP API实例 HttpClient.HandleRedirects := True; HttpClient.Request.ContentType := 'application/json'; HttpClient.Request.BasicAuthentication := True; HttpClient.Request.Authentication := TIdBasicAuthentication.Create; HttpClient.Request.Authentication.Username := 'appKey'; HttpClient.Request.Authentication.Password := 'masterSecret'; messageStr :='{"platform": "all","audience" : "all","notification" : {"alert" : "Hi, JPush for delphi!","android" : {},"ios" : {"extras" : { "newsid" : 321}}}}'; jsonToSend := TStringStream.Create(messageStr, TEncoding.UTF8); jsonToSend.Position := 0; Memo1.Text := HttpClient.Post('https://api.jpush.cn/v3/push', jsonToSend);
注:记得在窗体上加上“IdSSLIOHandlerSocketOpenSSL1”以及idhttp里面IOHandler为“IdSSLIOHandlerSocketOpenSSL1”不然会报“IOHandler value is not valid.”错误。
相关阅读 >>
Delphi socket connect timeout 套字节链接超时设置
Delphi comparedatetime、comparedate、comparetime、samedatetime、samedate、sametime �c 对比时间的函数
更多相关阅读请进入《Delphi》频道 >>