Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在delphi中通过SMS网关发送SMS_Delphi_Http Post_Delphi Xe2_Sms Gateway - Fatal编程技术网

在delphi中通过SMS网关发送SMS

在delphi中通过SMS网关发送SMS,delphi,http-post,delphi-xe2,sms-gateway,Delphi,Http Post,Delphi Xe2,Sms Gateway,网关网站提供的代码可在 我尽了最大的努力来实现这一点,但我不知道。谷歌搜索了很多次,但都无济于事。这是一个很酷的东西,可以在程序中实现,所以我希望详细的答案能够帮助很多人。它似乎是post,所以可能是我错误地解释了参数?任何帮助或投入都是有价值的。请原谅任何格式错误?第一次张贴到网站。顺便说一句,使用delphixe4。消息输出在下面的链接中 以下是delphi代码: function tform1.PostExample: string; var param:TStringLi

网关网站提供的代码可在 我尽了最大的努力来实现这一点,但我不知道。谷歌搜索了很多次,但都无济于事。这是一个很酷的东西,可以在程序中实现,所以我希望详细的答案能够帮助很多人。它似乎是post,所以可能是我错误地解释了参数?任何帮助或投入都是有价值的。请原谅任何格式错误?第一次张贴到网站。顺便说一句,使用delphixe4。消息输出在下面的链接中

以下是delphi代码:

function tform1.PostExample: string;
     var    param:TStringList;
            valid:boolean;
            url,text:string;
            http:TIDHttp;
      begin
         http := TIDHttp.Create(nil);
         http.HandleRedirects := true;
         http.ReadTimeout := 5000;
         param:=TStringList.create;
         param.Clear;
         param.Add('access_token=994ad8885430************91b6eb8f');
         param.Add('message=Test');
         param.Add('send_to=0729122723');
         valid:=true;
         url:='http://www.FreeSMSGateway.com/api_send';
          try
            text:=http.Post(url,param);
          except
           on E:Exception do
            begin
             valid:=false;
            end;
          end;
         if valid then
          showmessage( text )
          else
          showmessage( '' );
         end;
         end.
请仔细阅读:

使用以下POST变量向发送POST调用:

  • access_令牌:帐户仪表板中的API访问令牌
  • 消息:url编码的消息,不超过160个字符
  • send_to:此值必须为“existing_contacts”才能发送到您帐户中的所有现有联系人,或为“post_contacts”提供自定义联系人列表
  • post_contacts:发送消息的联系人的JSON数组,而不是您现有的联系人。只需要将“发送至”设置为“发送联系人”
您的
send_to
param值不符合所述要求。您在
send_to
字段中传递特定联系人号码,但必须在
post_contacts
字段中传递该联系人,例如:

param.Add('access_token=994ad8885430************91b6eb8f');
param.Add('message=Test');
//param.Add('send_to=0729122723');
param.Add('send_to=post_contacts');
param.Add('post_contacts=["0729122723"]'); // you may need to double-check this syntax