【发布时间】:2016-06-19 18:36:27
【问题描述】:
我目前正在从事一个在多个网站上实现 API 集成的项目。
随着我的进展,我注意到我在我的项目中使用了过多的 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
}
}
【问题讨论】:
标签: php jquery ajax api laravel-5.2