本文整理自网络,侵删。
下面是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 判断目录是否存在,不存在则创建目录并打开,存在则直接打开
Delphi combobox 只读 text属性可用的方法
Delphi webbrowser1提取网页中的所有链接、点击第 n 个链接
更多相关阅读请进入《Delphi》频道 >>