html link (href) 代码在 php 变量中用作短信的文本
Dynamic html link (href) code in php variable which is being used as a text for a sms
我有一个场景,我是 运行 一个短信营销活动,其中每条短信都包含一些带有 link 的文本。这个 link 是动态的,根据用户的不同,每个短信都不同。
我的短信内容 - "Dear user, please click here to perform the activity. "
下面是我使用的代码。
$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);
我觉得这没有错误,但我收到的短信仍然是这样的 -
我在哪里我在这里做错了。请指教
所以我认为 SMS 仅从 SMS 网关提供商以纯文本形式发送。
我使用的解决方案是使用有点短 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;
我的最终文本是这样的 -
Dear User, Please visit http://shortlurllink and perform the activity.
它做的工作和我之前想要的一样,所以我得到了我想要的。 :)
感谢@hassan 的开始。
我有一个场景,我是 运行 一个短信营销活动,其中每条短信都包含一些带有 link 的文本。这个 link 是动态的,根据用户的不同,每个短信都不同。 我的短信内容 - "Dear user, please click here to perform the activity. "
下面是我使用的代码。
$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);
我觉得这没有错误,但我收到的短信仍然是这样的 -
我在哪里我在这里做错了。请指教
所以我认为 SMS 仅从 SMS 网关提供商以纯文本形式发送。 我使用的解决方案是使用有点短 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;
我的最终文本是这样的 -
Dear User, Please visit http://shortlurllink and perform the activity.
它做的工作和我之前想要的一样,所以我得到了我想要的。 :)
感谢@hassan 的开始。