What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress API as example]
erbhaveshkumar123
erbhaveshkumar123 April 23, 2017

Promote your Mobile App in minutes with CPIDroid™

Signup now to start promoting your Android , iOS , Web app
Cheap & Fast just with your Mobile App link.

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment.

[caption id="attachment_567" align="aligncenter" width="550"]What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress JSON API as example] What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress JSON API as example][/caption]

I have used WordPress JSON API as an example to help you understand it much better. Also, you can use the code to develop an Application with WordPress JSON API (JetPack Plugin is required)

What is JSON ?

First of all, Let me tell you what is JSON.
JSON stands from JavaScript Object Notation. It is lightweight and widely used for data-interchange format.
One can easily convert and array into JSON data for API purpose. humans can easily read and write data in JSON format. Also for machines, It is easy to parse and generate data in JSON format from any other format such as array.

Main use of JSON (API) ?

There are many websites on the Internet who offers API for providing there private data present in their secured database to general public for Application Programming purpose. API stands for Application Programming Interface which provide an interface between any two servers for exchanging secured data without giving direct access to their secured databases.

Now, I am going to start the Tutorial, The Tutorial will be for PHP environment.

How to Fetch JSON Data from an API ?

You can fetch JSON Data from an API by using file_get_contents(); function which is already available in PHP :-

I am taking WordPress JSON API available through JetPack as an example in this tutorial as given below

API: https://public-api.wordpress.com/rest/v1.1/sites/blog.thesmartware.com/posts/536

This API link will return data of this Post (ID: 536) in JSON format, You can visit it to see the JSON response live in you web browser or alternatively you can use WordPress Developer Console: https://developer.wordpress.com/docs/api/console/

 

How to Decode JSON data from an API ?

The data stored in variable $JSON which is shown below, just for more understanding. This is the actual data in JSON format returned by the API server over the API URL link to the requesting server.

(Snippet given below is just for better understanding)

{
    "ID": 536,
    "site_ID": 90410154,
    "author": {
        "ID": 2,
        "login": "erbhaveshkumar123",
        "email": false,
        "name": "erbhaveshkumar123",
        "first_name": "BHAVESH",
        "last_name": "KUMAR",
        "nice_name": "erbhaveshkumar123",
        "URL": "http://bhaveshkumar.me/",
        "avatar_URL": "http://magzinly.com/wp-content/plugins/userpro/img/default_avatar_male.jpg",
        "profile_URL": "http://en.gravatar.com/1f393ceb53a2ba18d1c962196380cc4a"
    },
    "date": "2016-01-03T21:16:04+05:30",
    "modified": "2016-01-03T21:16:04+05:30",
    "title": "What is JSON ? How to Fetch, Decode & Handle JSON Data from an API using PHP ?",
    "URL": "http://magzinly.com/?p=536",
    "short_URL": "http://wp.me/p67lOi-8E",
    "content": "

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment.

\n

What is JSON ?

\n

First of all, Let me tell you what is JSON,
\nJSON stands from JavaScript Object Notation. It is lightweight and widely used for data-interchange format.
\nOne can easily convert and array into JSON data for API purpose. humans can easily read and write data in JSON format. Also for machines, It is easy to parse and generate data in JSON format from any other format such as array.

\n

Learn more about JSON at JSON Tutorial by Tutorial4Us !

\n

Main use of JSON (API) ?

\n

There are many websites on the Internet who offer API for providing there private data present in their secured database to public for Application programming purpose. API stands for Application Programming Interface which provide an interface between two Servers for exchanging secured data without letting them to get direct access to their secured databases.

\n

Now, I am going to start the Tutorial, The Tutorial will be from PHP environment.

\n

How to Get or Fetch JSON Data from an API ?

\n

You can get or fetch JSON Data from an API by using file_get_contents(); function which is already available in PHP :-

\n
 
\n

How to Decode JSON Data from an API ?

\n
 
\n

How to Handle JSON Data from an API ?

\n
 
\n

 

\n", "excerpt": "

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment. What...

\n", "slug": "how-to-get-or-fetch-decode-handle-json-data-from-an-api-using-php", "guid": "http://magzinly.com/?p=536", "status": "draft", "sticky": false, "password": "", "parent": false, "type": "post", "discussion": { "comments_open": true, "comment_status": "open", "pings_open": true, "ping_status": "open", "comment_count": 0 }, "likes_enabled": true, "sharing_enabled": true, "like_count": 0, "i_like": false, "is_reblogged": false, "is_following": true, "global_ID": "c52b856d27393e8eb61521e1d58247e7", "featured_image": "", "format": "standard", "geo": false, "menu_order": 0, "page_template": "", "publicize_URLs": [], "tags": {}, "categories": { "API": { "ID": 97, "name": "API", "slug": "api", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:api", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:api/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 86 }, "JSON": { "ID": 98, "name": "JSON", "slug": "json", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:json", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:json/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 97 }, "PHP": { "ID": 96, "name": "PHP", "slug": "php", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:php", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:php/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 95 }, "Programming": { "ID": 95, "name": "Programming", "slug": "programming", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:programming", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:programming/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 86 }, "Tutorials": { "ID": 86, "name": "Tutorials", "slug": "tutorials", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:tutorials", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:tutorials/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 0 } }, "attachments": {}, "attachment_count": 0, "metadata": [ { "id": "3528", "key": "restrict_roles", "value": "" }, { "id": "3534", "key": "wp_review_bgcolor1", "value": "#e7e7e7" }, { "id": "3535", "key": "wp_review_bgcolor2", "value": "#ffffff" }, { "id": "3536", "key": "wp_review_bordercolor", "value": "#e7e7e7" }, { "id": "3532", "key": "wp_review_color", "value": "#1e73be" }, { "id": "3530", "key": "wp_review_desc_title", "value": "Summary" }, { "id": "3533", "key": "wp_review_fontcolor", "value": "#555555" }, { "id": "3529", "key": "wp_review_location", "value": "bottom" } ], "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154", "replies": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/replies/", "likes": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/likes/" } }, "capabilities": { "publish_post": true, "delete_post": true, "edit_post": true }, "other_URLs": { "suggested_slug": "how-to-get-or-fetch-decode-handle-json-data-from-an-api-using-php", "permalink_URL": "http://magzinly.com/%postname%" }, "_headers": { "Date": "Sun, 03 Jan 2016 15:46:37 GMT", "Content-Type": "application/json" } }

Decoding the JSON format using json_decode()  function to convert the JSON formatted data into an Array (or Group of Arrays)

 

The Array you will get after above code is executed will be stored & available in variable $Responce

You can check the values stored in variable $Responce using print_r() function which will show you the structure of Array, it will help you in understanding & handling of Array.

(Snippet given below is just for better understanding)

Array
(
    [ID] => 536
    [site_ID] => 90410154
    [author] => Array
        (
            [ID] => 2
            [login] => erbhaveshkumar123
            [email] => 
            [name] => erbhaveshkumar123
            [first_name] => BHAVESH
            [last_name] => KUMAR
            [nice_name] => erbhaveshkumar123
            [URL] => http://bhaveshkumar.me/
            [avatar_URL] => http://magzinly.com/wp-content/plugins/userpro/img/default_avatar_male.jpg
            [profile_URL] => http://en.gravatar.com/1f393ceb53a2ba18d1c962196380cc4a
        )

    [date] => 2016-01-03T23:59:45+05:30
    [modified] => 2016-01-04T00:01:01+05:30
    [title] => What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress JSON API as example]
    [URL] => http://magzinly.com/json-fetch-decode-handle-json-data-api-using-php-wordpress-json-api-example
    [short_URL] => http://wp.me/p67lOi-8E
    [content] =>

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment. I have used WordPress JSON API as an example to help you understand it much better. Also, you can use the code to develop an Application with WordPress JSON API (JetPack Plugin is required)

What is JSON ?

First of all, Let me tell you what is JSON.
JSON stands from JavaScript Object Notation. It is lightweight and widely used for data-interchange format.
One can easily convert and array into JSON data for API purpose. humans can easily read and write data in JSON format. Also for machines, It is easy to parse and generate data in JSON format from any other format such as array.

Learn more about JSON at JSON Tutorial by Tutorial4Us !

Main use of JSON (API) ?

There are many websites on the Internet who offers API for providing there private data present in their secured database to general public for Application Programming purpose. API stands for Application Programming Interface which provide an interface between any two servers for exchanging secured data without giving direct access to their secured databases.

Now, I am going to start the Tutorial, The Tutorial will be for PHP environment.

How to Fetch JSON Data from an API ?

You can fetch JSON Data from an API by using file_get_contents(); function which is already available in PHP :-

I am taking WordPress JSON API available through JetPack as an example in this tutorial as given below

API: https://public-api.wordpress.com/rest/v1.1/sites/blog.thesmartware.com/posts/536

This API link will return data of this Post (ID: 536) in JSON format, You can visit it to see the JSON response live in you web browser or alternatively you can use WordPress Developer Console: https://developer.wordpress.com/docs/api/console/

 

How to Decode JSON data from an API ?

The data stored in variable $JSON which is shown below, just for more understanding. This is the actual data in JSON format returned by the API server over the API URL link to the requesting server.

{
    "ID": 536,
    "site_ID": 90410154,
    "author": {
        "ID": 2,
        "login": "erbhaveshkumar123",
        "email": false,
        "name": "erbhaveshkumar123",
        "first_name": "BHAVESH",
        "last_name": "KUMAR",
        "nice_name": "erbhaveshkumar123",
        "URL": "http://bhaveshkumar.me/",
        "avatar_URL": "http://magzinly.com/wp-content/plugins/userpro/img/default_avatar_male.jpg",
        "profile_URL": "http://en.gravatar.com/1f393ceb53a2ba18d1c962196380cc4a"
    },
    "date": "2016-01-03T21:16:04+05:30",
    "modified": "2016-01-03T21:16:04+05:30",
    "title": "What is JSON ? How to Fetch, Decode & Handle JSON Data from an API using PHP ?",
    "URL": "http://magzinly.com/?p=536",
    "short_URL": "http://wp.me/p67lOi-8E",
    "content": "

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment.

\n

What is JSON ?

\n

First of all, Let me tell you what is JSON,
\nJSON stands from JavaScript Object Notation. It is lightweight and widely used for data-interchange format.
\nOne can easily convert and array into JSON data for API purpose. humans can easily read and write data in JSON format. Also for machines, It is easy to parse and generate data in JSON format from any other format such as array.

\n

Learn more about JSON at JSON Tutorial by Tutorial4Us !

\n

Main use of JSON (API) ?

\n

There are many websites on the Internet who offer API for providing there private data present in their secured database to public for Application programming purpose. API stands for Application Programming Interface which provide an interface between two Servers for exchanging secured data without letting them to get direct access to their secured databases.

\n

Now, I am going to start the Tutorial, The Tutorial will be from PHP environment.

\n

How to Get or Fetch JSON Data from an API ?

\n

You can get or fetch JSON Data from an API by using file_get_contents(); function which is already available in PHP :-

\n
 
\n

How to Decode JSON Data from an API ?

\n
 
\n

How to Handle JSON Data from an API ?

\n
 
\n

 

\n", "excerpt": "

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment. What...

\n", "slug": "how-to-get-or-fetch-decode-handle-json-data-from-an-api-using-php", "guid": "http://magzinly.com/?p=536", "status": "draft", "sticky": false, "password": "", "parent": false, "type": "post", "discussion": { "comments_open": true, "comment_status": "open", "pings_open": true, "ping_status": "open", "comment_count": 0 }, "likes_enabled": true, "sharing_enabled": true, "like_count": 0, "i_like": false, "is_reblogged": false, "is_following": true, "global_ID": "c52b856d27393e8eb61521e1d58247e7", "featured_image": "", "format": "standard", "geo": false, "menu_order": 0, "page_template": "", "publicize_URLs": [], "tags": {}, "categories": { "API": { "ID": 97, "name": "API", "slug": "api", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:api", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:api/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 86 }, "JSON": { "ID": 98, "name": "JSON", "slug": "json", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:json", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:json/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 97 }, "PHP": { "ID": 96, "name": "PHP", "slug": "php", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:php", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:php/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 95 }, "Programming": { "ID": 95, "name": "Programming", "slug": "programming", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:programming", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:programming/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 86 }, "Tutorials": { "ID": 86, "name": "Tutorials", "slug": "tutorials", "description": "", "post_count": 0, "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:tutorials", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:tutorials/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154" } }, "parent": 0 } }, "attachments": {}, "attachment_count": 0, "metadata": [ { "id": "3528", "key": "restrict_roles", "value": "" }, { "id": "3534", "key": "wp_review_bgcolor1", "value": "#e7e7e7" }, { "id": "3535", "key": "wp_review_bgcolor2", "value": "#ffffff" }, { "id": "3536", "key": "wp_review_bordercolor", "value": "#e7e7e7" }, { "id": "3532", "key": "wp_review_color", "value": "#1e73be" }, { "id": "3530", "key": "wp_review_desc_title", "value": "Summary" }, { "id": "3533", "key": "wp_review_fontcolor", "value": "#555555" }, { "id": "3529", "key": "wp_review_location", "value": "bottom" } ], "meta": { "links": { "self": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536", "help": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/help", "site": "https://public-api.wordpress.com/rest/v1.1/sites/90410154", "replies": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/replies/", "likes": "https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/likes/" } }, "capabilities": { "publish_post": true, "delete_post": true, "edit_post": true }, "other_URLs": { "suggested_slug": "how-to-get-or-fetch-decode-handle-json-data-from-an-api-using-php", "permalink_URL": "http://magzinly.com/%postname%" }, "_headers": { "Date": "Sun, 03 Jan 2016 15:46:37 GMT", "Content-Type": "application/json" } }

Decoding the JSON format using json_decode() function to convert the JSON formatted data into an Array (or Group of Arrays)

 

The Array you will get after above code is executed will be stored & available in variable $Responce

You can check the values stored in variable $Responce using print_r() function which will show you the structure of Array, it will help you in understanding & handling of Array.

PHP Array 
{
        'pending' : 'will add soon after this post is published';
}

How to Handle JSON Data from an API ?

 

The Final Code will look like (Complete Code) :-


The Final OutPut will look like :-

Post Title: What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress JSON API as example]
Post URL: http://magzinly.com/?p=536
Post Excerpt: In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment. I…

Author Login: erbhaveshkumaar123
Comment Count: 0


Please feel free to ask any question or give suggestions or if you need any help either by commenting below or at our 1Ask (Q&A) and 1Forum

[excerpt] =>

In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment. I...

[slug] => json-fetch-decode-handle-json-data-api-using-php-wordpress-json-api-example [guid] => http://magzinly.com/?p=536 [status] => publish [sticky] => [password] => [parent] => [type] => post [discussion] => Array ( [comments_open] => 1 [comment_status] => open [pings_open] => 1 [ping_status] => open [comment_count] => 0 ) [likes_enabled] => 1 [sharing_enabled] => 1 [like_count] => 0 [i_like] => [is_reblogged] => [is_following] => [global_ID] => c52b856d27393e8eb61521e1d58247e7 [featured_image] => [format] => standard [geo] => [menu_order] => 0 [page_template] => [publicize_URLs] => Array ( ) [tags] => Array ( [API] => Array ( [ID] => 105 [name] => API [slug] => api [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:api [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:api/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [file_get_contents()] => Array ( [ID] => 104 [name] => file_get_contents() [slug] => file_get_contents [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:file_get_contents [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:file_get_contents/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [JSON] => Array ( [ID] => 101 [name] => JSON [slug] => json [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:json [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:json/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [JSON API] => Array ( [ID] => 100 [name] => JSON API [slug] => json-api [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:json-api [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:json-api/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [json_decode()] => Array ( [ID] => 107 [name] => json_decode() [slug] => json_decode [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:json_decode [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:json_decode/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [PHP] => Array ( [ID] => 102 [name] => PHP [slug] => php [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:php [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:php/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [PHP Code] => Array ( [ID] => 99 [name] => PHP Code [slug] => php-code [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:php-code [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:php-code/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [print_r()] => Array ( [ID] => 106 [name] => print_r() [slug] => print_r [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:print_r [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:print_r/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) [WordPress JSON API] => Array ( [ID] => 103 [name] => WordPress JSON API [slug] => wordpress-json-api [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:wordpress-json-api [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/tags/slug:wordpress-json-api/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) ) ) [categories] => Array ( [API] => Array ( [ID] => 97 [name] => API [slug] => api [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:api [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:api/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) [parent] => 86 ) [JSON] => Array ( [ID] => 98 [name] => JSON [slug] => json [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:json [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:json/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) [parent] => 97 ) [PHP] => Array ( [ID] => 96 [name] => PHP [slug] => php [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:php [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:php/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) [parent] => 95 ) [Programming] => Array ( [ID] => 95 [name] => Programming [slug] => programming [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:programming [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:programming/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) [parent] => 86 ) [Tutorials] => Array ( [ID] => 86 [name] => Tutorials [slug] => tutorials [description] => [post_count] => 1 [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:tutorials [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/categories/slug:tutorials/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 ) ) [parent] => 0 ) ) [attachments] => Array ( ) [attachment_count] => 0 [metadata] => Array ( [0] => Array ( [id] => 3624 [key] => _wpas_done_all [value] => 1 ) [1] => Array ( [id] => 3581 [key] => _wpas_mess [value] => What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress JSON API as example] ) [2] => Array ( [id] => 3631 [key] => _wpas_skip_11682191 [value] => 1 ) [3] => Array ( [id] => 3632 [key] => _wpas_skip_13187454 [value] => 1 ) [4] => Array ( [id] => 3633 [key] => _wpas_skip_13187473 [value] => 1 ) ) [meta] => Array ( [links] => Array ( [self] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536 [help] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/help [site] => https://public-api.wordpress.com/rest/v1.1/sites/90410154 [replies] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/replies/ [likes] => https://public-api.wordpress.com/rest/v1.1/sites/90410154/posts/536/likes/ ) ) [capabilities] => Array ( [publish_post] => [delete_post] => [edit_post] => ) [other_URLs] => Array ( ) )

How to Handle JSON Data from an API ?

 

The Final Code will look like (Complete Code) :-


The Final OutPut will look like :-

[alert-announce]Post Title: What is JSON ? How to Fetch, Decode & Handle JSON data from an API using PHP ? [WordPress JSON API as example]
Post URL: http://magzinly.com/what-is-json-how-to-fetch-decode-handle-json-data-from-an-api-using-php-wordpress-json-api-as-example
Post Excerpt: In this tutorial, I will teach you and help you to understand that how to handle JSON Data from an API in PHP environment. I...

Author Login: erbhaveshkumaar123
Comment Count: 0[/alert-announce]


Please feel free to ask any question or give suggestions or if you need any help either by commenting below or at our 1Ask (Q&A) and 1Forum

SignUp Now to Get FREE Access to our All in One Digital Marketing Platform!

We will continue to update Front; if you have any questions or suggestions, please contact us!

Follow us on Facebook, Instagram, Twitter, Pinterest, Linkedin, YouTube, and Medium.

erbhaveshkumar123
Written by

erbhaveshkumar123

I create advanced website builders made exclusively for web developers.

3 Comments

Image Description
Dave Austin 1 day ago

As a Special Education teacher this resonates so well with me. Fighting with gen ed teachers to flatten for the students with learning disabilities. It also confirms some things for me in my writing.

Reply
Image Description
Hanna Wolfe 1 day ago

Love it Dave! We're all about keeping it up.

Reply
Image Description
Maria Muszynska 2 days ago

Since our attention spans seem to be shrinking by the day — keeping it simple is more important than ever.

Reply

Post a comment

Stay in the know

Get special offers and the latest news updates from ElanceMarket™.