短信集成的Magento API [英] SMS Integration with Magento API

查看:347
本文介绍了短信集成的Magento API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Magento的1.8.1,我想将SMS与我们的商店进行整合。

我有短信API网址,但不知道如何以及在哪里把那个URL在Magento。

他们给我提供这个code:

\r
\r

< PHP\r
类sendsms\r
{\r
 私人$ api_url;\r
 私人$时间;\r
 私人$ UNI code;\r
私人$ working_key;\r
私人$启动;\r
私人$ SENDER_ID;\r
公共$ API;\r
公共$周;\r
公共$ SID;\r
公共$到;\r
\r
/ **函数来设置工作密钥\r
*\r
* @参数STRING_TYPE $ WK:有助于改变working_key\r
* /\r
功能setWorkingKey($周)\r
{\r
$这个 - > working_key = $周;\r
}\r
\r
/ **功能设置发件人ID\r
*\r
* @参数STRING_TYPE $ SID:有助于改变SENDER_ID\r
* /\r
功能setSenderId($ SID)\r
{\r
$这个 - > SENDER_ID = $ SID;\r
}\r
\r
/ **功能设置API网址\r
*\r
* @参数STRING_TYPE $ apiurl:它是用来设置API URL\r
* /\r
功能setapiurl($ apiurl)\r
{$这个 - > API = $ apiurl;\r
$ A =用strtolower(SUBSTR($ apiurl,0,7));\r
\r
如果($ A ==HTTP://)//检查是否已经包含HTTP://\r
{\r
$ api_url = SUBSTR($ apiurl,7,strlen的($ apiurl));\r
$这个 - > api_url = $ api_url;\r
$这个 - >开始=HTTP://;\r
}\r
ELSEIF($ A ==HTTPS:/)//检查是否已经包含HTPS://\r
{\r
$ api_url = SUBSTR($ apiurl,8,strlen的($ apiurl));\r
$这个 - > api_url = $ api_url;\r
$这个 - >开始=htt​​ps://开头;\r
}\r
其他{\r
$这个 - > api_url = $ apiurl;\r
$这个 - >开始=HTTP://;\r
}\r
}\r
\r
/ **功能并初始化构造\r
*\r
* @参数STRING_TYPE $ WK:这是working_key\r
* @参数STRING_TYPE $ SD:这是SENDER_ID\r
* @参数STRING_TYPE $ apiurl:它是api_url\r
*用于intializing参数\r
* /\r
功能__construct($ apiurl,$周,$ SD)\r
{\r
$这个 - > setWorkingKey($周);\r
$这个 - > setSenderId($ SD);\r
$这个 - > setapiurl($ apiurl);\r
}\r
\r
/ **\r
*函数来发送短信\r
*\r
* /\r
功能send_sms($到,$消息,$ dlr_url,$ TYPE =XML)\r
{\r
$这个 - > process_sms($到,$消息,$ dlr_url,$ TYPE =XML,$时间=空,$ UNI code =空);\r
}\r
\r
/ **\r
*功能,日程安排短信\r
*\r
* /\r
功能schedule_sms($到,$消息,$ dlr_url,$ TYPE =XML,$时间)\r
{\r
$这个 - > process_sms($到,$消息,$ dlr_url,$ TYPE =XML,$时,$ UNI code ='');\r
}\r
\r
/ **\r
*函数来发送UNI code消息\r
* /\r
功能UNI code_sms($到,$消息,$ dlr_url,$ TYPE =XML,$ UNI code)\r
{\r
$这个 - > process_sms($到,$消息,$ dlr_url,$ TYPE =XML,$时间='',$ UNI code);\r
}\r
\r
/ **\r
*功能发送SMS\r
* @参数STRING_TYPE $到:在这里需要消息被发送的手机号码\r
* @参数STRING_TYPE $消息:这是邮件内容\r
* @参数STRING_TYPE $ dlr_url:它是用于递送报告给客户\r
* @参数STRING_TYPE $型:在报告交付\r
* @返回输出$这个 - > API = $ apiurl;\r
* /\r
功能process_sms($到,$消息,$ dlr_url =,$ TYPE =XML,$时间='',$ UNI code ='')\r
{\r
$消息= urlen code($消息);\r
$这个 - >至= $到;\r
$为= SUBSTR($到,-1​​0);\r
$ arrayto =阵列(9,8,7);\r
$ to_check = SUBSTR($到,0,1);\r
\r
如果(in_array($ to_check,$ arrayto))\r
$这个 - >至= $到;\r
其他回声无效号码;\r
\r
如果($时间=='空')\r
$时间='';\r
其他\r
$ =时间与&时间= $时间;\r
如果($ UNI code =='空')\r
$ UNI code ='';\r
其他\r
$ UNI code =&放大器; UNI code = $ UNI code;\r
\r
\r
$url=\"$this->start$this->api_url/web2sms.php?workingkey=$this->working_key&sender=$this->sender_id&to=$to&message=$message&type=$type&dlr_url=$dlr_url$time$uni$c$c\";\r
$这个 - >执行($网址);\r
}\r
\r
/ **\r
*函数来检查的消息传递状态\r
* STRING_TYPE $中期:这是消息ID\r
* /\r
功能messagedelivery_status($中旬)\r
{\r
$url=\"$this->start$this->api_url/status.php?workingkey=$this->working_key&messageid=$mid\";\r
$这个 - >执行($网址);\r
}\r
\r
/ **\r
*函数来检查组消息传递\r
* STRING_TYPE $ GID:这是组ID\r
* /\r
功能groupdelivery_status($ GID)\r
{\r
$url=\"$this->start$this->api_url/groupstatus.php?workingkey=$this->working_key&messagegid=$gid\";\r
$这个 - >执行($网址);\r
\r
}\r
\r
/ **\r
*函数来请求给克伦特网址\r
* /\r
函数执行($网址)\r
{\r
$ CH = curl_init();\r
// curl_setopt($ CH,CURLOPT_POST,真正的);\r
curl_setopt($ CH,CURLOPT_URL,$网址);\r
curl_setopt($ CH,CURLOPT_RETURNTRANSFER,真正的);\r
curl_setopt($ CH,CURLOPT_SSL_VERIFYPEER,FALSE);\r
$输出= curl_exec($ CH);\r
curl_close($ CH);\r
回声$输出;\r
返回$输出;\r
\r
}\r
}

\r

\r
\r

我是新来的Magento,所以请帮助我的API集成。


解决方案

有免费提供的模块,比如春边缘的Magento短信延伸
这是兼容:
Magento的版本1.6.1,1.6.2.0,1.7,1.8,1.8.1,1.9

Magento的短信模块事件配置:

*下订单时。
*当订单状态设置为持有。
*当订单状态设置为恢复通话。
*当订单被取消。
*当订单状态设置出货。

http://springedge.com/magento-sms-extension-module- free.html

I am using Magento 1.8.1 and I want to integrate SMS with our store.

I have an API URL of SMS but don't know how and where to put that URL in Magento.

They provide me this code:

<?php 
class sendsms
{
 	private $api_url;
 	private $time;
 	private $unicode;
	private $working_key;
	private $start;
	private $sender_id;
	public  $api;
	public  $wk;
	public  $sid;
	public  $to;

	/**function to set the working key
	 * 
	 * @param string_type $wk:helps to change the working_key
	 */
	function setWorkingKey($wk)
	{   
		$this->working_key=$wk;
	}
	
	/**function to set sender id
	 * 
	 * @param string_type $sid:helps to change sender_id
	 */
	function setSenderId($sid)
	{   
		$this->sender_id=$sid;
	}

	/**function to set API url
	 * 
	 * @param string_type $apiurl:it is used to set api url
	 */
	function setapiurl($apiurl)
	{		$this->api=$apiurl;
			$a=strtolower(substr($apiurl,0,7));
			 
			 if ($a=="http://") //checking if already contains http://
			 {
			 	$api_url=substr($apiurl,7,strlen($apiurl));
			 	$this->api_url=$api_url;
			 	$this->start="http://";
			 }
		    elseif ($a=="https:/") //checking if already contains htps://
			 {
			 	$api_url=substr($apiurl,8,strlen($apiurl));
			 	$this->api_url=$api_url;
			 	$this->start="https://";
			 }
			 else { 
			 			$this->api_url=$apiurl;
			       		$this->start="http://";
			 	  }
	}

	/** function to intialize constructor
	 * 
	 * @param string_type $wk: it is working_key
	 * @param string_type $sd: it is sender_id
	 * @param string_type $apiurl: it is api_url
	 *          used for intializing the parameter
	 */
	function __construct($apiurl,$wk,$sd)
	{
		$this->setWorkingKey($wk);
		$this->setSenderId($sd);
		$this->setapiurl($apiurl);
	}

	/**
	 * function to send sms
	 * 
	 */
	function send_sms($to,$message,$dlr_url,$type="xml")
	{
		$this->process_sms($to,$message,$dlr_url,$type="xml",$time="null",$unicode="null");
	}

	/**
	 * function to schedule sms
	 * 
	 */
	function schedule_sms($to,$message,$dlr_url,$type="xml",$time)
	{ 
		$this->process_sms($to,$message,$dlr_url,$type="xml",$time,$unicode='');
	}

	/**
	 * function to send unicode message
	 */
	function unicode_sms($to,$message,$dlr_url,$type="xml",$unicode)
	{  
		$this->process_sms($to,$message,$dlr_url,$type="xml",$time='',$unicode);
	}

	/**
	 * function to send out sms
	 * @param string_type $to : is mobile number where message needs to be send
	 * @param string_type $message :it is message content
	 * @param string_type $dlr_url: it is used for delivering report to client
	 * @param string_type $type: type in which report is delivered
	 * @return output		$this->api=$apiurl;
	 */
	function process_sms($to,$message,$dlr_url="",$type="xml",$time='',$unicode='')
	{  
		$message=urlencode($message);
		$this->to=$to;
		$to=substr($to,-10) ;
		$arrayto=array("9", "8" ,"7");
		$to_check=substr($to,0,1);
	
	 if(in_array($to_check, $arrayto))
	 	$this->to=$to;
	 else echo "invalid number";

	if($time=='null')
		$time='';
	else
		$time="&time=$time";
	if($unicode=='null')
		$unicode='';
	else
		$unicode="&unicode=$unicode";
	
	 	
	 	$url="$this->start$this->api_url/web2sms.php?workingkey=$this->working_key&sender=$this->sender_id&to=$to&message=$message&type=$type&dlr_url=$dlr_url$time$unicode";
	 	$this->execute($url);
	}

	/**
	 * function to check message delivery status
	 * string_type $mid : it is message id 
	 */
	function messagedelivery_status($mid)
	{
		$url="$this->start$this->api_url/status.php?workingkey=$this->working_key&messageid=$mid";
			$this->execute($url);
	}

	/**
	 * function to check group message delivery
	 *  string_type $gid: it is group id
	 */
	function groupdelivery_status($gid)
	{
		 $url="$this->start$this->api_url/groupstatus.php?workingkey=$this->working_key&messagegid=$gid";
		$this->execute($url);
		
	}

	/**
	 * function to request to clent url
	 */
	function execute($url)
	{
		$ch=curl_init();
		// curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$output=curl_exec($ch);
		curl_close($ch);
		echo $output;
		return $output;
		
	}    
}

I am new to Magento, so please help me with the API integration.

解决方案

There are free modules available like "Spring Edge Magento sms extension" which is Compatible with: Magento versions 1.6.1, 1.6.2.0, 1.7, 1.8, 1.8.1, 1.9

Magento sms module events configuration :

*When Order is placed. * When order status is set to hold. * When order status is set to Unhold. * When order is cancelled. * When order status is set Shipment.

http://springedge.com/magento-sms-extension-module-free.html

这篇关于短信集成的Magento API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆