You’d call RecipeParser::parse() when you are creating the post content for your new post as a result of something being published on another site. The URL would be whatever is used to get the remote content — the permalink. The HTML would be what ever the response is after requesting that permalink.
The big question is how does your code know when new content is published on a remote site? It depends on the site. If it has a RSS feed, you can check that. If it’s a site with a REST API like WP, you could periodically query for recent posts. If it’s another site you control, the remote site could actually add posts to your site through your site’s own REST API, provided the authentication can be worked out.
Thanks for the feedback. I’m planning on using rss feed. Do you think there is any ready made rss php that comes with a plugin menu so I can use submit feed and then pass the content to RecipeParser::parse(). Ive been having a hard time trying to create one myself and I’ve tried using Simplepie.
Sorry, I’m not the best person to ask about what’s available. Frankly, RSS sounds like a pain to me, unless you can control the outgoing feed as well. You don’t really know what you’re going to get. Then you need to coordinate the output with posts you’ve already retrieved. If you don’t do so often enough, posts could drop off the end without your app seeing them.
I’d be inclined to use the REST API. You can query for posts that were published after a certain date/time. You’ll only get what you need. It’ll come in JSON format, which is generally easier to deal with. I don’t know how the recipe parser would deal with JSON, it may be fine. You can always extract the content for it if need be.
It’s not my place to tell you what to do, but that’s what I would do 🙂
It doesnt necessarily need to be RSS. I just need something that can automatically fetch the html file and url of a content so I can pass it to the Recipe Parser. Read https://github.com/onetsp/RecipeParser/blob/master/README.md. What do I do? Will php Curl work?
If cURL is available on your server, then yes, that’s a good choice. Consider using the REST API for getting the content you need. The link is to the specific request parameters you can use. Of particular interest is “after”. You can keep track of when the last post was received, and periodically get posts after that date. If you’re not familiar with this API, you’ll want to review the rest of the Handbook into which I’ve linked.
I’ve been assuming the external sources of recipes to parse are also WP sites. If not, then RSS feeds might be your only choice unless other CMS platforms also have a REST API. I’m not sure how widely supported REST is. Another possibility is XML-RPC.