• I’m trying to use the Yelp API to get some data for my website, and I’m mostly new at writing web apps. From what I see, my options are PHP, Java, and Python. However Java and Python both seem to require a framework/interface to run on a website and I’m not sure how that would play with the WP theme and install.

    So I assume the simplest way, since a WP website already runs on PHP, would be to write a simple program in PHP to query the API, and put the code in a .php file in my child theme? Is this correct, or are there merits to getting the Python or Java frameworks up instead?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I think PHP would be a better option here all things considered. I would put it in a custom plugin instead of the child theme though. When you switch themes later you won’t have to move the code.

    Thread Starter melange

    (@melange)

    Thanks for the suggestion, mindctrl! I would have preferred to write in Python since the code is a lot more compact, but I don’t think it would be worth getting Django etc to run on my server.

    Is there any overhead to writing a custom plugin, or can I just write the .php file the same way I would otherwise and then just put it in a plugin folder?

    Hi Melange,

    Overhead can be medium at worst, for example i was praying WP Dynamic Sidebar, which is a plugin that can be called on every rendered page, but final result is a very low footprint on performance.

    Sometimes, you can hard-code it on the theme, sometimes it’s better to really write a plugin because it’s repeat stuff you want in most of pages.

    A plugin is really for repeat stuff – in theory better for performance but that depends if you do call 4 apis at real-time on same page. If the plugin is called at every php/html process, go for it. But if not, it’s both waste of coding time and performance too.

    Anyways WordPress is very flexible on what you can do.

    Thread Starter melange

    (@melange)

    Thanks Digico.

    I don’t plan on hard-coding it in the theme for sure, I plan on putting it in a child theme. I was hoping that if I segregate my application logic well enough, then when I change themes in the future I can just copy my old child theme’s .php files over into the new child theme with a few minor modifications. Or is that unrealistic?

    As far as overhead goes, adding a custom plugin and writing the same code into a theme will result in around 99.9999999% the same overhead. You still need the same code, it will still run the same, and the only difference is one or two files that you might need to load.

    On top of that the biggest reason for writing this as a plugin is that it won’t be theme-dependant, so you can use any theme you want at any time without needing ot go copying stuff across anywhere.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Simplest way to use 3rd party API’ is closed to new replies.