lucky/msg91

Msg91 PHP API 库。

dev-master 2017-09-19 11:03 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:34:12 UTC


README

Msg91 PHP API 文档。

  • 文本短信
  • 发送OTP
  • 分销商
  • 通讯录
  • 虚拟号码

通过composer安装

  • 步骤1:在composer.json的所需部分添加此依赖项
 "lucky/msg91":"dev-master"
  • 步骤1:运行此操作之后
compoer update
  • 步骤3:完成此操作后,您需要导入vendor/autoload.php

注意:如果之前没有导入自动加载文件,则步骤3是必需的。

如何使用

  • 现在您需要创建Msg91的对象

要创建Msg91对象,您需要传递您的Msg91 AuthKey。这样,您就可以探索Msg91提供的所有功能了。

 // create an object of msg91
 $msg91 = new \lucky\Msg91\Msg91('Msg91-User-Authkey');

注意:这里只展示了几个基本操作

发送文本短信

  • 使用Msg91对象发送文本短信的示例。
    $mobiles = "919999999999"; // mobile no. to whom you want to send sms. Including country code.
    $message = " your text sms will come up here"; // Message content to send
    $sender = "MSGIND"; // Receiver will see this as sender's ID.
    $route = "1"; // Route you want to use. 1 for promotional route and 4 for transactional route 
    $country = "Country_code"; //numeric	0 for international,1 for USA, 91 for India.

    $data = array( "authkey" => AUTH_KEY,
                    "mobiles" => $mobiles,
                    "message" => $message,
                    "sender" => $sender,
                    "route" => $route,
                    "country" => $country,
                 );

    $output = $msg91->sendSMS($data);

发送OTP

  • 发送OTP消息的示例
    $mobile = "919999999999"; // Keep number in international format (with country code)
    $sender = "OTPSMS";   // Receiver will see this as sender's ID. (default : OTPSMS)
	
    // Message content to send. (default : Your verification code is ##OTP##.)
    $message = "Your verification code is ##OTP##."; 
	
    $data = array( "authkey" => AUTH_KEY,
		   "mobile" => $mobile,
		   "message" => $message,
		   "sender" => $sender,
	         );
	              
    $output = $msg91->otp->sendOTP($data);

分销商操作

  • 添加客户

    	$user_full_name     =   "fname lname";     //(varchar)	Full name of user
	$user_name          =   "user_name";   //(varchar) User's name
	$user_mobile_number =   "user_mobile_number";        //(int) User's mobile
	$user_email         =   "user_email";   //(varchar) User's email
	$user_company_name  =   "user_company_name";         //(varchar) User's company name
	$user_industry      =   "user_industry";         //(varchar) User's industry
	$user_expiry        =    "user_expiry";         //(int) Expiry date of user's account
	$user_country_code  =    "user_country_code";               //(int) User country code

	$data = array( "authkey" => AUTH_KEY,
	               "user_full_name" => $user_company_name,  
	               "user_name"=> $user_name,           
	               "user_mobile_number" =>$user_mobile_number,
	               "user_email" => $user_email,       
	               "user_company_name"=>$user_company_name,  
	               "user_industry"=> $user_industry,    
	               "user_expiry" => $user_expiry,      
	               "user_country_code" => $user_country_code,
	             );

	$output = $msg91->sendOTP($data);
  • 客户TO列表

    $data = array( "authkey" => AUTH_KEY  );
    
	$output = $msg91->listClient($data);

通讯录操作

  • 添加联系人

    $name = "contact name";  //contact name
    $mob_no = "mobile no"; //mobile no.
    $group = "group ID"; // group ID
 
     $data = array( "authkey" => AUTH_KEY,
	            "name" => $name,
	            "mob_no" => $mob_no,
	            "group" => $group,
                  );

    $output = $msg91->addClient($data);
  • 删除客户

    $contact_id="contact id";  //contact id
    $data = array( "authkey" => AUTH_KEY,
		   "contact_id" => $contact_id,
		 );
		
	$output = $msg91->deleteContact($data);