Switch cURL to wp_remote_get()
robertandrews opened this issue · 1 comments
Plugin currently makes the Google NLP API call using PHP's cURL command.
Reddit recommendations advise moving to wp_remote_get.
I believe my latest commit accomplishes this.
9c804ca#diff-22ada278963de00fa9693671fde37717
Following cxt-term-tidier being my first ever real WordPress plugin and my first commit, this represents my first iteration, first Issue to be resolved, first enhancement.
Thanks for the suggestion.
The enhancement switches the method through which Google's NLP API is called, from cURL in PHP to wp_remote_post(), a WordPress function that - I am advised - is best used in a WordPress environment and which can decide on the best underlying method to use for itself, which may end up being cURL.
I read a bit more about the correct way to formulate a wp_remote_post() call, tried a few things, dummied the output from this method side-by-side with that from the cURL method so I could see what was coming through. The result is formatted slightly differently from the cURL method, which meant a bit of extra work was needed to isolate the correct part of the result.
Happy with this.