POST request not going through?

I found that it didn’t work because both endpoints used the same route. I expected defining one for POST and one for GET would result in different callbacks, but they apparently conflict with each other. In a first time, I get the request going through simply by change the namespace for the POST. Maybe there … Read more

Get all PDF files from page with WordPress API

You would get the PDFs by querying mime_type=application/pdf So, based on your example your full URL would be: https://www.domain.com/wp-json/wp/v2/media?parent=1267&mime_type=application/pdf However, it is possible when using the parent=ID parameter, you will see ALL the PDFs, not just the attachments specific to that post. This happens when the PDFs were uploaded to the media library, but not … Read more

WP_REMOTE_POST Requests are being blocked by API provider [closed]

If the API is expecting a JSON object you should change your args to: $args = array ( ‘sslverify’ => false, ‘data_format’ => ‘body’, ‘headers’ => [ ‘Authorization: Bearer {API_KEY}’, ‘Content-Type: application/json’ ], ‘body’ => json_encode([ ‘region’ => ‘USA’, ‘plan’ => 1, ‘label’ => ‘API Test’, ‘app_id’ => 2 ]), ); Encode your data into … Read more

woocommerce registration form with klaviyo(don’t work with current user)

Hey guys there are just a few changes in the above code. Check this out it works for me. Note: Please change the LIST_ID to your klaviyo’s list id, and get one private key from your klaviyo account and add it at PRIVATE_API_KEY function send_coupon_to_freshly_registered_user($user_id) { $user = get_user_by(‘id’,$user_id); //new line $user_email = stripslashes($user->user_email); //changed … Read more

How send get request to external api with username and password

Watch your keys: $headers = array( // ‘headers’ => array( // this is duplicated ‘Authorization’ => ‘Basic ‘ . base64_encode( ‘username:password’ ), ‘Accept’ => ‘application/xml’ // ) ); $res = wp_remote_request( $url, array( ‘method’ => ‘GET’, ‘headers’ => $headers ) ); Don’t send headers inside headers. Using a variable name different from args can help … Read more

Integrate ZOHO Recruit API?

Basically, what you’ll need to do is XML-ize your data and POST it to the API URLs they provide. I’ll start out with the basic request, and we can build on the solution if you want. <?php $api_key = ‘API_KEY’; // insert your API key here; $ticket=”TICKET_ID”; // your ticket here (should be with your … Read more

get_option() fails to return binary result

Found the problem. And A WORD OF WARNING to people MIGRATING their WordPress Installations. Read this to understand how get_option is going to start failing when unserializing binary data from the DB. What I did was to migrate my WordPress the hardcore way: copy all files to the web server, restore the full SQL database … Read more

Sending WP posts to external API

I think the better way to handle it would be to have the other site scrape the feed for the content. Alternately, you could call an API on the receiving server with every execution of the publish_posts hook, but this would leave you with the issue of not being able to concurrently edit. Another solution … Read more