【问题标题】:Sending an SMS via sms gateway in delphi在delphi中通过短信网关发送短信
【发布时间】:2013-07-29 18:54:10
【问题描述】:

网关网站“提供”的代码位于http://www.freesmsgateway.com/api 我尽力实现这一点,但不知道。谷歌广泛搜索无济于事。这在程序中实现非常酷,所以我希望详细的答案能够帮助很多人。它似乎发布了,所以也许我把参数解释错了?任何帮助或输入都是有价值的。请原谅任何格式错误?第一次在网站上发布海报。顺便说一句,使用德尔福 XE4。消息输出在showmessage returned text下面的链接中。

这里是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.

【问题讨论】:

    标签: delphi http-post delphi-xe2 sms-gateway


    【解决方案1】:

    再仔细阅读the documentatation

    使用以下 POST 变量向 http://www.FreeSMSGateway.com/api_send 发送 POST 调用:

    • access_token:您的帐户仪表板中的 API 访问令牌
    • message:url 编码的消息,160 个字符或更少
    • send_to:此值需要为“existing_contacts”以发送给您帐户中的所有现有联系人,或“post_contacts”以提供自定义联系人列表
    • post_contacts:要向其发送消息的联系人的 JSON 数组,而不是您现有的联系人。仅需要将“send_to”设置为“post_contacts”

    您的send_to 参数值不符合规定的要求。您在 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多