Tôi đang sử dụng Laravel. Dưới đây là một lớp học tôi đang làm việc trên:Gọi chức năng khác trong cùng một bộ điều khiển?
<?php
class InstagramController extends BaseController {
/*
|--------------------------------------------------------------------------
| Default Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| Route::get('/', '[email protected]');
|
*/
public function read($q)
{
$client_id = 'ea7bee895ef34ed08eacad639f515897';
$uri = 'https://api.instagram.com/v1/tags/'.$q.'/media/recent?client_id='.$client_id;
return sendRequest($uri);
}
public function sendRequest($uri){
$curl = curl_init($uri);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
}
Dòng:
return sendRequest($uri);
ám chỉ rằng lỗi: Gọi đến chức năng xác định sendRequest()
Tôi giả định đó là vì tôi đề cập đến chức năng theo cách sai, nhưng tôi không thể tìm thấy bất kỳ lời giải thích nào về cách thực hiện nó.
Bạn có thể muốn bảo vệ sendRequest. –