• samuelalake

    (@samuelalake)


    I’m a newbie learning php and I’ve been trying to convert the zip file of a php library that I found on github to a wordpress plugin.

    But i dont understand what this line means.

    “Call RecipeParser::parse(), passing in the contents of an HTML file that includes a recipe and, optionally, the URL of the original page, which helps to identify specific parsers to use.”

    Where do I call that code and automatically pass in content for html and different url. Is there a function that I’m missing?

    I want the plugin to automatically create a new blog post of parsed recipes every time a content is published on certain websites. Is this even possible

    This is the guthub link. https://github.com/onetsp/RecipeParser/blob/master/README.md. Thank you in advance.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    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.

    Thread Starter samuelalake

    (@samuelalake)

    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.

    Moderator bcworkz

    (@bcworkz)

    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 ??

    Thread Starter samuelalake

    (@samuelalake)

    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?

    Moderator bcworkz

    (@bcworkz)

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trying to convert php library from github to wordpress plugin.’ is closed to new replies.