Xe8 or later use
Vhttp: = Tnethttpclient.create (nil);
VList: = tstringlist.create;
VS: = tstringstream.create;
Try
MEMO1.LINES.ADD ('----------------post blocking----------------');
Vs.clear;
With Vhttp do
Begin
ConnectionTimeout: = 2000; 2 seconds
Responsetimeout: = 10000; 10 seconds
Acceptcharset: = ' utf-8 ';
Acceptencoding: = ' UTF-8 ';
Acceptlanguage: = ' ZH-CN ';
Accept: = ' application/json; ';
ContentType: = ' Application/json; Charset=utf-8; ';
UserAgent: = ' Embarcadero URI client/1.0 ';
customheaders[' Authorization ']: =
' Basic ffffffffffffyfytftfghfhffffffffffffffffffffffffffffgfhgfhgf== ';
Try
SS: = Tstringstream. Create ("', tencoding. UTF8);
Ss. WriteString (' {"mobile": "XXXXXXXX", "temp_id": 1} ');
Post (' Https://api.sms.jpush.cn/v1/codes ', SS, VS); UTF8 into the GBK
Memo1.Lines.Add (' Post: ' + vs.datastring);
Except
On E:exception do
Memo1.Lines.Add (' Post: ' + e.message);
End
=============
Indy Way online Push SMS not tried:)
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);
Delphi calls Aurora texting nethttpclient