-
What’s your URL? This is the easiest way for others to help you
Listing of and Links to Our Blog Articles - **What version of Ghost are you using?
V3 Hosted by Ghost Pro
And
- How was Ghost installed and configured? Ghost Pro
- What Node version, database, OS & browser are you using? Ghost Pro
- What errors or information do you see in the console? No errors
- What steps could someone else take to reproduce the issue you’re having? See the URL above
Our main site is on a server different from our Ghost blog. I am trying to access the Content API from our main site using PHP. I have successfully built a page on our main site using the Content API and the JavaScript Content API Client (see here: Index of and Links to Our Blog Articles), but am having a hard time figuring out how to do the same using PHP. I’m not a PHP expert: I can find and modify examples and get things to work, but that’s about it.
In my PHP example, I am replacing the code inserted by the JavaScript client with:
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://stout-bowman-associates-
llc.ghost.io/ghost/api/v3/content/tags/?key=73af8261b1543c9a9446538e98&fields=name,slug');
$result = curl_exec($curl);
print_r($result);
curl_close($curl);
?>
You can see the result on the test PHP page. When I place this reponse from the Content API into an online JSON validator, it complains that it is not valid JSON, so that may be why I can’t get the PHP JSON functions to operate on the response. I need to extract the name of the tag and the slug in order to build the list of tags on the page.
Also, if you look at the List of Posts section, you’ll see that, while I request the post with:
curl_setopt($curl, CURLOPT_URL, 'https://stout-bowman-associates-llc.ghost.io/ghost/api/v3/content/posts/?key=73af8261b1543c9a9446538e98&fields=title,published_at,plaintext,url');
I am not getting the plaintext for the posts. Has anyone used PHP to retrieve this data from the Content API and can show me an example I can use? Thanks in advance.