我正在尝试使用SMS INDIA HUB API向用户发送一次密码。为此,我需要重定向到URL格式:
如果我们加载此URL,它将返回一些消息。我需要收到该信息。
我尝试过这样
$url = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=wwww&password=eee&msisdn=9197xxxxx&sid=yyyyy&msg=rrrrr&fl=0&gwid=2";
return Redirect::intended($url);
但这并不指向该链接。它尝试将URL加载到localhost中。
还是有任何使用SMS INDIA HUB发送短信的插件?
有人可以帮忙吗?
您应该能够像这样重定向到网址
return Redirect::to($url);
定义您要重定向的URL $url
然后使用
return Redirect::away($url);
如果要在视图内重定向,请使用
return Redirect::to($url);
更新1:
这是简单的例子
return Redirect::to('http://www.google.com');
更新2:
由于发问者想在同一页面中返回
$triggersms = file_get_contents('http://www.cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=efg&password=abcd&msisdn=9197xxx2&sid=MYID&msg=Hello');
return $triggersms;
对于Laravel 5.x / 6.x / 7.x,请使用:
return redirect()->away('https://www.google.com');
如文档中所述:
有时您可能需要重定向到应用程序外部的域。您可以通过调用away方法来执行此操作,该方法将创建RedirectResponse,而无需任何其他URL编码,验证或验证:
您可以使用 Redirect::away($url)
对于Laravel 5.x,我们可以使用
return redirect()->to($url);
另外,增加班级
use Illuminate\Http\RedirectResponse;
之后,像这样:
public function show($id){
$link = Link::findOrFail($id); // get data from db table Links
return new RedirectResponse($link->url); // and this my external link,
}
要么 -
return new RedirectResponse("http://www.google.com?andParams=yourParams");
对于外部链接,必须使用完整的URL字符串(开头带有'http')。
return Redirect::away($url);
应该工作重定向
另外,return Redirect::to($url);
在视图内重定向。
如果您使用的是InertiaJS,则该away()
方法将无法像在惯性JS github上看到的那样工作,他们正在讨论在惯性JS上创建“外部重定向”的最佳方法,目前的解决方案是返回409状态,并通过X-Inertia-Location
标头告知网址, 像这样:
return response('', 409)
->header('X-Inertia-Location', $paymentLink);
其中的paymentLink是您要将用户发送到的链接。
消息来源:https : //github.com/inertiajs/inertia-laravel/issues/57#issuecomment-570581851
文章标签:laravel , laravel-4 , php , sms-gateway
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
评论已关闭!