【问题标题】:Dynamic html link (href) code in php variable which is being used as a text for a smsphp 变量中的动态 html 链接(href)代码,用作短信的文本
【发布时间】:2017-10-21 00:36:04
【问题描述】:

我有一个场景,我正在运行一个短信活动,其中每个短信都包含一些带有链接的文本。此链接是动态的,并且对于基于用户的每个短信都是不同的。 我的短信内容——“亲爱的用户,请click here进行活动。”

下面是我正在使用的代码。

$smsusername = 'xxxxxx';
$smspassword = 'xxxxxx';
$destination = $phone;
$url = "http://www.example.com/?id=1" 
$source = 'SENDER-NM';
$text1 = 'Dear User, Please ';
$parturl = '<a href="$url">click here </a>';
$text2 = 'to perform the activity.';

$text = $text1 . $parturl . $text2;

$content =  'action=sendsms'.
            '&user='.rawurlencode($smsusername).
            '&password='.rawurlencode($smspassword).
            '&to='.rawurlencode($destination).
            '&from='.rawurlencode($source).
            '&text='.rawurlencode($text);

$smsglobal_response = file_get_contents('http://www.smsglobal.com.au/http-api.php?'.$content);

$explode_response = explode('SMSGlobalMsgID:', $smsglobal_response);

我觉得这没有错误,但我收到的短信仍然是这样的 -

我在哪里做错了。请指教

【问题讨论】:

  • 似乎是您的短信以纯文本形式发送,请提供有关您的短信 API 的更多详细信息或联系该 API 支持团队。
  • @hassan : 我在这里使用 smsglobal 的 api 来发送短信。这是它的文档 - smsglobal.com/http-api/…
  • 很难找到任何关于在那里发送 HTML 内容的线索,我认为他们不支持 HTML ,即使使用 email-api smsglobal.com/services ,你会发现“确保邮件正文是纯文本,不是 HTML。”

标签: php html sms


【解决方案1】:

所以我认为 SMS 仅从 SMS Gateway 提供商以纯文本形式发送。 我使用的解决方案是使用 bitly short link api -

$short_url = json_decode(file_get_contents("http://api.bit.ly/v3/shorten?login=mylogin&apiKey=myapikey&longUrl=".urlencode("$url")."&format=json"))->data->url;

并像这样创建短信内容 -

$text = $text1 . $short_url . $text2;

我的最终文本是这样的 -

尊敬的用户,请访问http://shortlurllink并进行活动。

它完成了我之前想要的相同工作,所以我得到了我想要的。 :)

感谢@hassan 的开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-30
    • 2017-12-22
    • 2013-11-30
    • 1970-01-01
    • 2021-06-20
    • 2017-10-12
    • 1970-01-01
    相关资源
    最近更新 更多