Automatically import content to wordpress from a json file

I have a scrape that generates content in JSON format and can be obtained by GET to a specific URL, the URL from which to extract information is this: https://api.webscraper.io/api/v1/scraping-job/4851593/json?api_token=aLXQWr2IbQCefgiLc1PfIjfx7GqvsBd3APVbU1pHchszzzFIFa6HFKsNmpft

I would like to be able to connect this with my WP so that the content is published automatically.

Topic json automation Wordpress

Category Web


You can use wp_insert_post() to add a new post programmatically. For Example,

$my_post = array(
  'post_title'    => wp_strip_all_tags( $json->title ),
  'post_content'  => $json->body,
  'post_status'   => 'publish',
  'post_author'   => 1,
  'post_category' => $json->categories
);
 
// Insert the post into the database
wp_insert_post( $my_post );

Your link has expired so I could not see the structure of JSON data. But the answer would be the same. Set up a cron job or use their webhook (if they have any) to call a page where you have set up this wp_insert_post()for automatic posting.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.