Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^3: Running JavaScript from within Perl

by marto (Archbishop)
on Sep 15, 2019 at 09:26 UTC ( #11106192=note: print w/replies, xml ) Need Help??

in reply to Re^2: Running JavaScript from within Perl
in thread Running JavaScript from within Perl

"I don't mind responses that go beyond the narrow bounds of what I asked. It's like learning a new language: sometimes it's best to immerse myself in the new culture and see what I can absorb."

The method described in the post you're replying to wont help you achieve what you asked to do. If you're interested in learning about JavaScript and HTML/DOM manipulation there are better resources (from the Mojolicious docs):

"All web development starts with HTML, CSS and JavaScript, to learn the basics we recommend the Mozilla Developer Network. And if you want to know more about how browsers and web servers actually communicate, there's also a very nice introduction to HTTP."

"I've downloaded and installed Vagrant, VirtualBox, and Git for Windows on my computer"

What part of problem does this solve?

"Is this a good resource? ("

I've no idea, you need to register to download an ebook.

"Do you know of any better (perhaps newer) tutorials for the WordPress REST API?"

What is missing from the official WordPress documentation?

Update: Re^3: Running JavaScript from within Perl (or just use the API)/

  • Comment on Re^3: Running JavaScript from within Perl

Replies are listed 'Best First'.
Re^4: Running JavaScript from within Perl
by anautismobserver (Sexton) on Sep 15, 2019 at 17:09 UTC

    Here's a link to the book:

    It offers a step-by-step guide to using the WordPress REST API. It recommends using VVV (Vagrant), and somewhere in the instructions were also recommendations for VirtualBox and Git.

    What's missing from the official WordPress documentation is a step-by-step guide to using the WordPress REST API for neophytes like me.

      Thanks for the links and the context. At a really quick glimpse the ebook suggests that you host your own WordPress sites locally for testing purposes. From what I've read so far you have an existing WordPress site and are looking to programmatically query some of the associated data from time to time, using it to do something or other. If this is the case, unless you want to work through this whole book, hosting sites locally for test purposes I suggest this is overkill.

      Without knowing how much you know I'll mention a few things. The WordPress docs I linked to explain how their REST interface should be used. If you have curl installed you can run their example code for followers (if you have provided authentication details matching their site, rather than the example they provide), and see the response it gives you.

      You could scrape this via WWW::Mechanize::Chrome, however it's always better to use an API if one exists, less subject to change, fewer prerequisites, often more portable. So depending on exactly what you want to achieve perl offers lots of ways to solve the problem, including REST::Client, HTTP::Request::FromCurl (this live demo lets you convert a curl request to perl code) and so on.

      Take a look, do some reading (Super Search is your friend), let us know if you have specific questions.

        When I tried to follow the official WordPress documentation I got stuck on the authorization requirement (how to get "YOUR_API_TOKEN"). The instructions confused me. I was hoping the book could walk me through that.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11106192]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2019-10-24 01:40 GMT
Find Nodes?
    Voting Booth?