Wordpress JSON API Plug-in: How can I put the output of a JSON query into a PHP string?

I installed the JSON API Plug-In for my wordpress site. I want to display on an external site how many posts I have in a certain category.

For example, I have a URL like this: http://mywordpress.com/?json=get_category_posts&slug=press%20releases

Along the output, I almost immediately see a field "post_count" and a number right after it. I want to encapsulate this number into a string so I can output that number onto a table. But in order for me to be able to do that I need to have the entire output in a variable.

But I can't have something like

$json-output = http://mywordpress.com/?json=get_category_posts&slug=press%20releases;
echo $json-output;

That's just gonna output the URL, not the result of the JSON query.

I hope the question is making sense. Any guidance would be appreciated.


You will need to use CURL to get the json result from the URL, then parse the json with PHP, then echo the item you would like displayed.

The parts you seem to be missing are the CURL and JSON parsing, but you are on the right track.

This might help, a pretty simple example: http://www.katcode.com/http-requests-using-curl-and-decoding-json-responses/

Need Your Help

Django - How to model this correctly?

python django model

I want to model the following situation. I have a table of items, and a table of players, and a player can have many items and have multiple copies of the same item. I can easily model the player h...

Image decoded from Base64 is getting smaller than the normal image.

android base64 decode

I can successfully convert the given Base64 string to corresponding image in Android.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.