Delphi 调用极光推送服务端HTTP API实例
2015-08-29 15:04
706 查看
下面是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.”错误。
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.”错误。
相关文章推荐
- 非action层获取HttpServletRequest
- c# 下载网络图片到本地
- HTTP状态码
- HTTP Content-type
- Http请求中Content-Type讲解以及在Spring MVC中的应用
- noip2003 神经网络 (拓扑排序,深搜)
- 使用AFNetWorking和ReactiveCocoa对网络请求进行封装(仿煎蛋iOS)(3)
- http 原生post 请求
- Spring中MultipartHttpServletRequest实现文件上传
- TCP.Receiver C# 版本TCP协议接收器 V1.0.03
- HTTP协议
- NS2网络仿真环境的搭建和使用
- c# http get post 用法
- python爬虫 - python requests网络请求简洁之道
- python爬虫 - python requests网络请求简洁之道
- 网络抓包以及进行简单数据分析
- C#异步SOCKET发送帮肋类,支持UDP,TCP
- Idiot的间谍网络
- [Q&A] 初次yum安装httpd 遇到的问题
- 新版XMLHttpRequest支持跨域请求