{"id":31,"date":"2021-01-14T07:44:35","date_gmt":"2021-01-14T07:44:35","guid":{"rendered":"https:\/\/mouryasolutions.in\/blog\/?p=31"},"modified":"2023-01-29T19:35:02","modified_gmt":"2023-01-29T19:35:02","slug":"fetch-data-from-firebase-database","status":"publish","type":"post","link":"https:\/\/mouryasolutions.in\/blog\/fetch-data-from-firebase-database\/","title":{"rendered":"How to fetch data from firebase with php"},"content":{"rendered":"<div class=\"post-content\">\r\n<blockquote class=\"wp-block-quote\">\r\n<p>You can fetch multiple records from Firebase Realtime Database using the Firebase Realtime Database REST API. Here is an example in PHP using the Guzzle HTTP Client:<\/p>\r\n<\/blockquote>\r\n\r\n\r\n\r\n<h4>First, install the Guzzle HTTP Client:<\/h4>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>composer require guzzlehttp\/guzzle\r\n<\/code><\/pre>\r\n\r\n\r\n\r\n<h4>Next, you can use the following code to fetch multiple records:<\/h4>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>use GuzzleHttp\\Client;\r\n\r\n$client = new Client();\r\n$response = $client-&gt;request('GET', 'https:\/\/&lt;DATABASE_NAME&gt;.firebaseio.com\/&lt;TABLE_NAME&gt;.json');\r\n$data = json_decode($response-&gt;getBody(), true);\r\n\r\nforeach ($data as $record) {\r\n    print_r($record);\r\n}\r\n<\/code><\/pre>\r\n\r\n\r\n\r\n<p>Note: Replace <code>&lt;DATABASE_NAME&gt;<\/code> and <code>&lt;TABLE_NAME&gt;<\/code> with your Firebase Realtime Database name and table name respectively.<\/p>\r\n<\/div>","protected":false},"excerpt":{"rendered":"<p>You can fetch multiple records from Firebase Realtime Database using<a href=\"https:\/\/mouryasolutions.in\/blog\/fetch-data-from-firebase-database\/\">Read More<i class=\"fa fa-long-arrow-right\" aria-hidden=\"true\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":509,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,10],"tags":[],"_links":{"self":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/31"}],"collection":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":12,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":511,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/31\/revisions\/511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/media\/509"}],"wp:attachment":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}