简体   繁体   English

任何人都知道如何使用 nexmo 短信 api 接收短信到 php 脚本

[英]anybody know how receive sms to php script using nexmo sms api

am trying to implement nexmo sms api to receive sms from phone and save to mysql table.我正在尝试实现 nexmo sms api 以从手机接收短信并保存到 mysql 表。 i took account in nexmo.我在 nexmo 中考虑到了。 i ckeched the documentation.我查看了文档。 but confused how to use it但很困惑如何使用它

https://docs.nexmo.com/messaging/sms-api
am trying to implement nexmo sms api to receive sms from phone and save to mysql table. i took account in nexmo. i ckeched the documentation. but confused how to use it

anybody knows how to receive sms to my script when sending sms from phone,then please help me i want to fetch sms to script and save to mysql table任何人都知道从手机发送短信时如何将短信接收到我的脚本,然后请帮助我我想将短信获取到脚本并保存到 mysql 表

public function myinformation() {
   $request = array_merge($_GET, $_POST);

// Check that this is a delivery receipt.
if (!isset($request['messageId']) OR !isset($request['status'])) {
    error_log('This is not a delivery receipt');
    return;
}

//Check if your message has been delivered correctly.
if ($request['status'] == 'delivered') {
    error_log("Your message to {$request['msisdn']} (message id {$request['messageId']}) was delivered.");
    error_log("The cost was {$request['price']}.");
     $From = $this->input->post('saleena@gmail.com');
        $ToEmail = $this->input->post('saleena@gmail.com');
        $message = "Results: " . print_r( $request, true );
           $this->load->library('email');
        $subject = 'My Attempt';

        // Get full html:
        $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=' . strtolower(config_item('charset')) . '" />
    <title>' . html_escape($subject) . '</title>
    <style type="text/css">
        body {
            font-family: Arial, Verdana, Helvetica, sans-serif;
            font-size: 16px;
        }
    </style>
</head>
<body>
' . $message . '
</body>
</html>';
      $result = $this->email
                ->from($From)
                // Optional, an account where a human being reads.
                ->to($ToEmail)
                ->subject($subject)
                ->message($body)
                ->send();

        var_dump($result);
        echo $this->email->print_debugger();
        exit;      

} elseif ($request['status'] != 'accepted') {
    error_log("Your message to {$request['msisdn']} (message id {$request['messageId']}) was accepted by the carrier.");
    error_log("The cost was {$request['price']}.");
} else {
    error_log("Your message to {$request['msisdn']} has a status of: {$request['status']}.");
    error_log("Check err-code {$request['err-code']} against the documentation.");
}
    }

i tried this code.but i didnt receive any mail to my mail我试过这个代码。但我没有收到任何邮件到我的邮箱

You can use Nexmo's SMS API which allows you to send a text in over 200 countries with a simple HTTP call.您可以使用 Nexmo 的 SMS API,它允许您通过简单的 HTTP 调用在 200 多个国家/地区发送文本。

You can sign up for a virtual number which allows you to send SMS messages & receive incoming message as well.您可以注册一个虚拟号码,它允许您发送短信和接收传入的消息。

For 2FA, you can use the Verify API to authenticate users to a specific device.对于 2FA,您可以使用验证 API 对特定设备的用户进行身份验证。

This method is more secure than using an SMS API and randomly generating numbers yourself.这种方法比使用 SMS API 和自己随机生成数字更安全。 The pin will then entered by the end user & checked by the Verify API. PIN 码将由最终用户输入并由验证 API 进行检查。

It takes a few lines of code to use either of these APIs.使用这些 API 中的任何一个都需要几行代码。 Below is a block of code in PHP which allows you to send a text using the SMS API.下面是一段 PHP 代码,它允许您使用 SMS API 发送文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM