Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
15 votes

How to use OAuth authentication with REST API via CURL commands?

Let's go step by step here. Looks like you're trying to use OAuth just for authentication, but before you can do so you need to get the Access Token which will be used to authenticate when you make ...
sMyles's user avatar
  • 2,836
8 votes
Accepted

cURL - How to send and fetch data in Wordpress

wp_remote_get() and wp_remote_post() and wp_remote_request() should answer on your questions.This is best practice for WordPress.
Maxim Sarandi's user avatar
7 votes

wp_remote_get - cURL error 28 - only on same domain

By default, WordPress set the timeout value for cURL in wp-includes/class-wp-http-curl.php to 5 seconds and the same value is also set to HTTP requests in wp-includes/class-http.php that is a newer ...
Ali Basheer's user avatar
5 votes
Accepted

cURL 28 error after switch from to brew php 7.2 on localhost

Try This First: Your Problem Might Be DNS In my testing this is a problem with DNS resolving. In my case it's because the DNS filter/cache I run on my local network wasn't responding to requests. ...
John B's user avatar
  • 346
4 votes
Accepted

Use WP admin AJAX url to hide API key

I would break this problem in to 2 parts. First, you could sent an Ajax request to your server, sending only the dataString variable. Then, you can use either cURL or wp_remote_get() on the server ...
Johansson's user avatar
  • 15.3k
3 votes

Download failed cURL error 7: . Can't update anything

In my case (running on Centos 8), this error was caused by SElinux preventing apache (the login running the web server) from using the connect(2) system call. Try running in permissive mode -- if ...
jhfrontz's user avatar
  • 131
3 votes
Accepted

How to convert this cURL to wp_remote_get?

The curl is sending a POST request, to convert this you'll want to use wp_remote_post(). As described in the documentation, the request arguments are the same as WP_Http::request(), so let's look ...
kero's user avatar
  • 6,210
3 votes
Accepted

Add media with WP-Rest-API v2 II

I suspect based on an answer at StackOverflow that something like this would work: base64credentials="...... " curl --request POST \ --url "http://www.yoursite.com/wp-json/wp/v2/media" \ --header "...
Tom J Nowell's user avatar
  • 59.4k
3 votes

Download file using cURL into wp-includes/uploads

There is special wp_upload_bits() function to upload the content to the 'uploads' directory. Also, there is no such directory as /wp-includes/upload/. The code was not tested! <?php $video_id = '...
Max Yudin's user avatar
  • 6,297
3 votes

Download file using cURL into wp-includes/uploads

I'd advice you to use WordPress' API functionality for this, like media_sideload_image(), media_handle_sideload() or media_handle_upload(). Just to name some of the obvious ones, in the end it is ...
Nicolai Grossherr's user avatar
3 votes

How to use OAuth authentication with REST API via CURL commands?

Adding this as another answer to give you help to figure out how to do this. Basically as mentioned in my comments if you're going to use OAuth1 you MUST associate it with a user account, no way ...
sMyles's user avatar
  • 2,836
3 votes

Uploading media with the REST API

This is not possible via the API; you need to fetch the image yourself, and send the data to the API yourself. Blockquote – This quotes Ryan on the GitHub–issue mentioned in @Dan (deleted) answer. ...
kaiser's user avatar
  • 50.6k
2 votes
Accepted

Using PODS data with save_post

Yes, whenever a post is saved you should see all of the input items in $_POST ... if you're not using something like xdebug to debug with, you could do something like: echo "<pre>"; var_dump( $...
sMyles's user avatar
  • 2,836
2 votes

Problem with cURL and rest API

The curl_init function accepts an url and what you are passing there looks like a command line call. Please check this link for an example of passing username and password through php curl ...
theodorhanu's user avatar
2 votes
Accepted

File Type Is Not Permitted - Cronjob

Defining ALLOW_UNFILTERED_UPLOADS isn't enough anymore: it doesn't grant the capability, it just permits non-admin users who have the unfiltered_uploads capability to upload any file (except on a ...
Rup's user avatar
  • 4,277
2 votes
Accepted

AJAX error handling for submit function in functions file

How can I reconfigure my JS so that code 400 will fire the error function in the AJAX call? The error callback in your $.ajax() setup will be fired if the server responded with a HTTP status header ...
Sally CJ's user avatar
  • 39.2k
2 votes
Accepted

How to use the HTTP API (wp_remote_get) instead of cURL?

So it looks like I've managed to fix my own problem here. I don't know if this is the best thinkable solution to this exact problem, but it does work! My assumptions about CURLOPT_FOLLOWLOCATION seem ...
DeltaG's user avatar
  • 899
1 vote
Accepted

Get single item from cURL plugin API call inside bash

Since it seems the API is closed source and there may not be a way to get only a single option then the only other option is parsing the response. I hear jq is the way to go for parsing JSON within ...
ecotechie's user avatar
1 vote
Accepted

cURL error for cron

This error is most often related to the server configuration! Contact your hosting company and ask the hosting support to check the following points: The server is running a recent version of PHP and ...
Rene Hermenau's user avatar
1 vote

Uploading a media item with the wp-json API to a specific path

Don't think this is possible, however will do a bit more research. Since the functionality to expose this isn't exposed by the server, you need to do something on the server side to enable this to ...
mozboz's user avatar
  • 2,558
1 vote
Accepted

Inconsistencies between wp_remote_post and cURL

As discovered above, headers need to be (seems so obvious now) key-value pairs, as opposed to an array of json-style key-values: $headers = array(); $headers['Content-Type'] = 'application/json'; $...
MikeiLL's user avatar
  • 569
1 vote
Accepted

WordPress transient not working with WP Engine

So I don't know why the return $cached_result; in the else, but if that's intentional, then you should probably do: return json_decode( $cached_result, true ); Because you're caching the response ...
Sally CJ's user avatar
  • 39.2k
1 vote
Accepted

How to send a HTTP Post request using PHP Curl and Wordpress

I managed to solve this by adding the following into my functions.php add_shortcode('my_shortode', 'my_function'); function my_function () { $curl = curl_init(); curl_setopt_array($curl, array( ...
user1348927's user avatar
1 vote

SOAP Request/Parsing XML From wp_send_json_success

Much easy: $xml = simplexml_load_string($response); wp_send_json_success([ "data" => $xml ]);
zqhmagic's user avatar
1 vote

REST API works in browser and via AJAX but fails via cURL

It seem I am very late for this question, but I post my experience to here anyway, and hope it can help anyone with similar experience, since it is so hard to google an answer for this kind of rare ...
Asuka165's user avatar
  • 111
1 vote

Where Does Wordpress Make cURL Requests? How To Add cURL Option

Not sure about your specific cURL script but the base cURL function can be found here inside of WordPress: https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/class-wp-http-curl.php#L220 ...
Tom's user avatar
  • 1,286
1 vote
Accepted

cURL error 6 on news area, and also won't auto update

I had the same problem and eventually found a solution today (actually, a friend of mine did it). What I did was to edit the /etc/nginx/nginx.conf file and add resolver ip address. The configuration ...
pml's user avatar
  • 126
1 vote

How to use OAuth authentication with REST API via CURL commands?

I know I'm coming into this a bit late, but can you use wp_remote_get and _post? I'm pulling and posting content with my wordpress install using them: THis is the general idea from the wordpress ...
rudtek's user avatar
  • 6,121

Only top scored, non community-wiki answers of a minimum length are eligible