如何在 Laravel 中发送短信

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49827284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:38:23  来源:igfitidea点击:

How to send SMS in laravel

laravelsms

提问by ISURU UDAYANGA BANDARA

Hello I created a food ordering system using Laravel. Now I want to send confirmation sms automatically to the customer when their order received I am creating this project as my university project not for commercial use so are there any free services that can I use?

您好,我使用 Laravel 创建了一个食品订购系统。现在我想在收到他们的订单时自动向客户发送确认短信我正在创建这个项目作为我的大学项目,不用于商业用途,所以我可以使用任何免费服务吗?

回答by parker_codes

These types of services almost always have a cost. They have been created via someone's time and efforts, and they charge for this.

这些类型的服务几乎总是有成本的。它们是通过某人的时间和努力创建的,他们为此收费。

That being said, there are some VERY cheap options out there. Here are probably the top 2:

话虽如此,那里有一些非常便宜的选择。这可能是前2名:

They both have great APIs and run at less than an American penny.

它们都有很棒的 AP​​I,而且运行成本不到一美分。

For example, to send a text using Plivo:

例如,要使用 Plivo 发送文本:

$response = $client->messages->create(
    '14153336666',
    '14156667777',
    'Test Message'
);

回答by Danny Brian

There are no free services but very very cheap services available for SMS. These cheap services are usually locale to a country.

SMS 没有免费服务,但非常便宜。这些廉价服务通常是针对某个国家/地区的。

Like Nigeria has BulkSmsNigeria, etc. Suggest you to google for "send sms services" and you'll find many.

像尼日利亚有 BulkSmsNigeria 等。建议你谷歌搜索“发送短信服务”,你会发现很多。

Now using them in Laravel is a cakewalk with the Laravel SMS API Plugin. It integrates with the Laravel notification system as well. Go through the plugin documentation for an easy understanding.

现在在 Laravel 中使用它们是Laravel SMS API 插件小菜一碟。它还与 Laravel 通知系统集成。浏览插件文档以便于理解。

回答by WebDeveloper.IM

You can use any laravel package. Most of the SMS gateway has integration API and documentation. Also, some may have a laravel package. You can try this one: https://github.com/intergo/sms.to-laravel-lumenit's easy to integrate with your app and offer international SMS services. Price is also the same as your local providers. Hope this helps.

您可以使用任何 Laravel 包。大多数 SMS 网关都有集成 API 和文档。此外,有些可能有 laravel 包。你可以试试这个:https: //github.com/intergo/sms.to-laravel-lumen它很容易与你的应用程序集成并提供国际短信服务。价格也与您当地的供应商相同。希望这可以帮助。

回答by user2182909

You can use SMSFactor's API alongside with their Laravel Packageto easily send SMS. You just need to create an account that comes with 10 free SMS so you can try it out. Then sending an SMS would look like this:

你可以使用SMSFactor的 API 和他们的Laravel 包来轻松发送短信。您只需要创建一个附带 10 条免费短信的帐户,即可试用。然后发送短信看起来像这样:

Message::send([
    'to' => '33600000000',
    'text' => 'Did you ever dance whith the devil in the pale moonlight ?'
]);
print_r($response->getJson());