0
我目前正在开发一个在几个站点上实现API集成的项目。如何在Laravel 5.2中直接从Controller发送API请求?
现在,我注意到我在我的项目中使用JQuery使用了太多的AJAX请求(其代码可在页面源上查看),并且我想尽可能地限制它。
是否有办法直接从Laravel 5.2中的任何控制器发送API请求,就像下面的代码一样?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HttpRequestController extends Controller
{
public function PostRequest($uri, $data) {
//functional code that will post the given data to the specified uri
}
public function GetRequest($uri) {
//functional code that will retrieve the given data via the specified uri
}
}
谢谢队友。我会仔细研究一下这个问题。 –