Postingan lainnya
Error HttpRequest, Fatal error: Uncaught Error: Class 'HttpRequest' not found in C:\xa
Saya sedang mencoba get api data kok begini ya? minta pencerahannya.
Fatal error: Uncaught Error: Class 'HttpRequest' not found in
C:\xampp\htdocs\nandar\token.php:2 Stack trace: #0 {main}
thrown in C:\xampp\htdocs\nandar\token.php on line 2
<?php
$request = new HttpRequest();
$request->setUrl('https://blabla.net/core/connect/token');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/x-www-form-urlencoded'
));
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
'grant_type' => 'client_credentials',
'client_id' => 'client-xxx',
'client_secret' => 'xxx',
'scope' => 'scope-xxx'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
2 Jawaban:
<div>Sertakan file library-nya gan...<br><br>Semoga membantu</div>
Tanggapan
tidak menggunakan library gan, wajib menggunakan library ya?
coba baca gan...
https://stackoverflow.com/questions/22726419/php-fatal-error-class-httprequest-not-found
maaf gan, itu bukan library, mungkin extension pecl-nya belum terinstal...
<div>Class HttpRequest disediakan oleh PECL extension. Mungkin di komputer mu, extension PECL nya belum terinstal.<br>Silahkan baca cara installasi nya via website resminya disini <a href="https://php.uz/manual/en/install.pecl.php">https://php.uz/manual/en/install.pecl.php</a><br><br>sebagai informasi, selain menggunakan HttpRequest, kamu bisa gunain CURL pada php untuk melakukan request pada restful api. Cek kelasnya disini <a href="https://sekolahkoding.com/kelas/belajar-curl-bahasa-indonesia">https://sekolahkoding.com/kelas/belajar-curl-bahasa-indonesia</a><br><br>Silahkan lihat referensi berikut :<br>- <a href="http://pecl.php.net/package/pecl_http">http://pecl.php.net/package/pecl_http</a><br>- <a href="https://stackoverflow.com/questions/22726419/php-fatal-error-class-httprequest-not-found">https://stackoverflow.com/questions/22726419/php-fatal-error-class-httprequest-not-found</a><br>- <a href="https://php.uz/manual/en/class.httprequest.php">https://php.uz/manual/en/class.httprequest.php</a><br><br>Semoga membantu.</div>