Я пытался реализовать вызов API Speci c из API, который я создал. Это необработанный PHP, рамки не используются. Просто обычный php файл . Поскольку я знаю, что я правильно реализовал код и несколько раз протестировал на сервере MAMP, но проблема в Каждый раз, когда я пытаюсь вызвать API, я получаю 500 Internal Server Error .
Я скачал файл Requests. php из этого скрипта из git: git clone git://github.com/rmccue/Requests.git
Путь к файлу определен правильно, так как я его повторно проверил ,
Возможно, файл запроса не реализуется. Включили файл запроса в мой файл php.
Код:
<?php
include('Applications/MAMP/htdocs/api/Requests/library/Requests.php');
$response = array();
$request_method = $_SERVER['REQUEST_METHOD'];
if( $request_method == 'GET' ){
Requests::register_autoloader();
$response = Requests::get('https://nut-case.s3.amazonaws.com/jobs.json');
echo $response;
}else {
echo 'No defined function for this method. Please use GET only';
}
?>
PHP Журналы ошибок
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:26:51 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1131134 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:27:04 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1113726 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:28:02 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1096318 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:28:16 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1113726 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
URL-адрес в порядке. Я пытаюсь мой API на моем локальном хосте, используя MAMP, и API работает нормально. Это для целей тестирования, так как я учу PHP впервые. Пожалуйста помоги. Спасибо