Postingan lainnya
Buku Ini Koding!
Baru!
Buku ini akan jadi teman perjalanan kamu belajar sampai dapat kerjaan di dunia programming!
Laravel Firebase, eror 404 Not Found saat POST data
Saya menggunakan Laravel 5.4 dan package Kreait/Firebase-php, tapi mengalami error 404 saat mencoba mengirim data.
In Controller :
public function fb(){
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/FirebaseKey.json');
$firebase = (new Factory)
->withServiceAccount($serviceAccount)
->create();
$database = $firebase->getDatabase();
$ref = $database->getReference('notifications');
$key = $ref->push()->getKey();
$ref->getChild($key)->set([
'pesan' => 'tes'
]);
return $key;
}
Pesan error :
(1/2) ClientException
Client error: `POST https://myapp-35d0f.firebaseio.com/notifications` resulted in a `404 Not Found` response:
{
"error" : "404 Not Found"
}
in RequestException.php line 113
at RequestException::create(object(Request), object(Response))in Middleware.php line 65
at Middleware::GuzzleHttp\{closure}(object(Response))in Promise.php line 204
at Promise::callHandler(1, object(Response), null)in Promise.php line 153
at Promise::GuzzleHttp\Promise\{closure}()in TaskQueue.php line 48
...........more
(2/2) ApiException
404 Not Found
in ApiException.php line 40
at ApiException::wrapRequestException(object(ClientException))in ApiClient.php line 83
at ApiClient->request('POST', object(Uri), array('json' => null))in ApiClient.php line 61
at ApiClient->push(object(Uri), null)in Reference.php line 353
at Reference->push()in UserController.php line 36
at UserController->fb()
at call_user_func_array(array(object(UserController), 'fb'), array())in Controller.php line 55
......... more
Mohon bantuannya, error tersebut disebabkan karna apa yah?
1 Jawaban:
Jawaban Terpilih
<div>Alhamdulillah sudah terpecahkan. Ternyata masalahya banyak.. mulai dari versi Laravel yang tidak compatible dengan package sampai masalah sertifikasi ssl cUrl pada local server.<br><br>Jadi untuk mengatasi problem yang ini saya melakukan :<br>1. Upgrade laravel ke versi 8 atau terbaru.<br>2. mengunduh certs.pem di curl.se<br>3. menyimpan certs.pem di directory xampp dan mendaftarkannya di php.ini<br>4. restart komputer<br><br>dan jadilah seperti apa yang saya inginkan :D</div>
Tanggapan
terima kasih sudah share