ardaryinsim / insim
insim - 通过API从移动设备发送短信
1.0.0
2023-03-24 09:45 UTC
This package is not auto-updated.
Last update: 2024-09-24 20:38:30 UTC
README
insim 允许您在需要时一次性发送多条消息或添加多个联系人
安装
$ composer require ardaryinsim/insim
用法
发送短信
<?php require_once __DIR__ . '/vendor/autoload.php'; use Ardaryinsim\Insim\InSim; $data='{"header":{"login":"user@gmail.com","accessKey":"xYGt5Dl9wKvz+#RGGU!PjVB+KfiJAYnh%z4&","mode":"prod","priority":2},"messages":[{"phone_number":"+33*****","message":"Hi Cassandra, can you confirm our appointement?","url":"https://www.my-link.com","priorite": 1,"date_to_send":"2022-10-29 10:16:10"},{"phone_number":"+33*****","message":"Dear customer, your package has been sent","url":"","priorite": 1,"date_to_send":"2022-10-29 10:16:10"}]}'; $api = new InSim(); $response=$api->sendSms($data); ?>
结果示例
[
{
"id_sms_api": "Pf7v16XZ38oT02s",
"sms_per_message": 1,
"user": "user@gmail.com",
"sent_time": "2022-10-29T14:12:53.996Z",
"phone_number": "+336**",
"message": "Hi Cassandra, can you confirm our appointement https://arsms.co/oloe00F6Vvsa \n \nSent for free from PC via arsms.co/free",
"sent": 1
},
{
"id_sms_api": "NDztErkiR98DHxB",
"sms_per_message": 1,
"user": "user@gmail.com",
"sent_time": "2022-10-29T14:12:53.996Z",
"phone_number": "+33******",
"message": "Dear customer, your package has been sent\n \nSent for free from PC via arsms.co/free",
"sent": 1
}
]
添加联系人
<?php require_once __DIR__ . '/vendor/autoload.php'; use Ardaryinsim\Insim\InSim; $data='{"header": [{ "login": "user@gmail.com","password": "YOUR_PASSWORD","api": true}], "contacts": [{ "phone_number": "+1XXXXXXXXXX", "first_name": "Doe","last_name": "Joe", "adress": "contact adress", "email": "contact_email@gmail.com", "country_code":"+XX" // Not in international format },{ "phone_number": "+1XXXXXXXXXX", "first_name": "Smith","last_name": "John","adress": "contact adress","email": "contact_email@gmail.com" }]}'; $api = new InSim(); $response=$api->addContact($data); ?>
结果示例: {
"data":{
"contact":[
{
"phone_number": "+1XXXXXXXXXX", // international format
"first_name": "Doe",
"last_name": "Joe",
"adress": "contact adress"
"email": "contact_email@gmail.com",
"result":"success"
},
{
"phone_number": "+1XXXXXXXXXX", // international format
"first_name": "Smith",
"last_name": "John",
"adress": "contact adress"
"email": "contact_email@gmail.com",
"result":"success"
}
]
}
}
URL 回调(您不需要单独安装api即可使用)
要使用URL回调以获取传入的Sms,Sms投递状态...您只需在您的回调URL中包含
消息投递状态案例
<?php $status_message =json_decode($_GET[« status »]); ?> $status_message is an object like this: { "user":"SENDER_LOGIN", "phone_number":"RECIPIENT", "status":"received", // values : "sent" or "received" "date_status":"2019-08-09T12:50:54.211Z", "id_sms_api":"YOUR_ID_SMS" // or the one we provide you if empty when sending }
获取传入消息案例
<?php $message =json_decode($_GET[« message »]); ?> $message is an object like this: { "title":"incoming sms", "from":"+1XXXXXXXXXX", // phone number (international format) "message":"Hello world !", "date":"2020-01-21 10:01:38" }
获取点击链接案例
<?php $click =json_decode($_GET[« click »]); ?> $click is an object like this: { "title":"clicked link", "phonenumber":"+1XXXXXXXXXX", // phone number (international format) "link":"https:\/\/www.my-link.com\/", "date":"2019-07-08 15:07:03", "id_sms_api":"YOUR_ID_SMS" // or the one we provide you if empty when sending }
获取通话记录案例
<?php $call =json_decode($_GET[« call »]); ?> $call is an object like this: { "TITLE":"INCOMING CALL", // or "OUTGOING CALL" or "MISSED" "PHONE_NUMBER":"+1XXXXXXXXXX", "CALL_TIME":"2019-07-05", "DURATION": "15:11:04" }
获取通话质量案例
<?php $qualification =json_decode($_GET["calls"]); ?> $qualification is an object like this: { "title":"Call qualification From Mobile",// or title can be "Call qualification From Interface" "from":"+1XXXXXXXXXX", // phone number (international format) "qualification":"Hello world !", "date":"2020-01-21 10:01:38" }