【问题标题】:How can i send OTP to users phone number in Laravel我如何将 OTP 发送到 Laravel 中的用户电话号码
【发布时间】:2021-04-14 11:03:37
【问题描述】:

我有 gupshup 帐户。我想在 laravel 中创建 api,它将使用 gupshup 帐户将 otp 发送到手机。我是 laravel 的新手

【问题讨论】:

    标签: laravel gupshup


    【解决方案1】:

    根据Outbound Messages 的 GupShup API 文档,您需要使用您的 API 密钥和信息向他们的服务器发出发布请求。

    Laravel 使用 Guzzle HTTP client 发出请求。您可以使用 HTTP 外观发出发布请求。下面是一个未经测试的示例:

    use Illuminate\Support\Facades\Http; // To be added to the top of your file where you add the code below
    
    // Put the following code in the function which sends out the OTP.
    $response = Http::withHeaders([
                      "Content-Type" => "application/x-www-form-urlencoded",
                      "apikey": "{{Your API Key}}" // replace with your API key
                       ])
                      ->post('https://api.gupshup.io/sm/api/v1/msg',
                           [
                           "channel" => "whatsapp",
                           "source" => "1111111111", // your business number
                           "destination" => "9999999999", // clients number
                           "src.name" => "Your App" // Your App Name
                           "message" => [
                                 "isHSM" => "false",
                                 "type" => "text",
                                 "text" => "{{Your OTP is XXXXX}}" // replace with text you want to send
                             ] 
                           ]
                          );
    
    

    【讨论】:

      猜你喜欢
      • 2020-02-24
      • 2020-03-10
      • 2020-05-26
      • 1970-01-01
      • 2018-10-22
      • 2021-04-30
      • 2016-04-15
      • 1970-01-01
      • 2019-11-17
      相关资源
      最近更新 更多