本文整理自网络,侵删。
下面是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 fdconnection1.gettablenames 查看所有表包含用户表和系统表
python4Delphi 示例应用程序在 Delphi 应用程序中运行简单的 python 脚本
Delphi 中 image 控件加载bmp、jpg、gif、png等图片的办法
更多相关阅读请进入《Delphi》频道 >>