EDIT: I think I discovered the issue, the endpoint is truncating the content response, does anyone know how to send over all of the data without it being truncated? So I stumbled across some inconsistencies when requesting posts from one of our websites and not being able to pull in ALL of the content for a specific post. Explanation: Let's say that we have our REST API endpoint from the website where the posts live: https://test.com/wp-json/wp/v2/posts. When I decode and …
Alright, I need some help and I don't know if I'm doing it the correct way, but I wanted to see if the community can guide me in a better direction. Here is what's going on: I have a register_rest_route() that calls the function (Not included in this code). I make a call to grab the endpoint headers where it contains the total pages $headers['headers']['x-wp-totalpages'] which is 80. I then loop through all the pages and call wp_remote_get to grab …
With this link https://api.wordpress.org/core/version-check/1.7 I get the latest version of Wordpress, now I need: Get the name WordPress default theme in the core, twentytwentyone. how? I tried https://api.wordpress.org/core/theme-check/1.7/
I want to create a WordPress website in which I want to display a search box on a page, where the user will be able to search for tracking numbers from different companies. On searching a string in the search box, an external API call should be made based on that string and the data returned by the API should be shown to the user. I've successfully fetched data from a test API, and the data is shown using custom …
We have a web app that will allow users to edit their videos; and add intros, outros, and watermarks. Once the user already done on their video. We need to provide an option to post or syndicate their video as a draft on their WordPress site. Our plan is to create a WordPress plugin that the user needs to install on their WordPress site. But our problem are the following: How can we authenticate our web app to the user's …
I want to create a simple wordpress website in which I want to display a search box on a page. On searching a string in text/search box, an external API call should be made based on that string and the data returned by the API should be shown to user. I have successfully referred code from below URL so far - https://rapidapi.com/blog/integrate-external-api-wordpress/. But I am not able to make a call to API based on string passed in text box. …
Ok, I've searched a lot but cannot understand what I'm missing. I need to post some data to a php file on another server, but if I print the wp_remote_post variable I get: {"headers":{},"body":"","response":{"code":200,"message":"OK"} ..... here the code: $url = 'https://xxx.domain.net/api/api.php'; $args = array( 'method' => 'POST', 'timeout' => 45, 'sslverify' => false, 'headers' => array( 'Authorization' => 'xxxx', 'Content-Type' => 'application/json; charset=utf-8', ), 'body' => json_encode($attachment_fields), 'data_format' => 'body' ); $request = wp_remote_post( $url, $args ); and $attachment_fields is …
I have a site with about 100 registered users. Some of the people will be receiving digital scales. The scales send their weight data to a 3rd party server that then sends a JSON Payload as an HTTP Post to a URL endpoint (my server). The message can include Basic authentication. Can anyone recommend the best approach to get the data into the WP database. Initially I just want to add the weight to their profile with user_metadata. Eventually I …
I am trying to access data from another website to display on a WordPress Website I am developing. So far I have the following: <?php /* Template Name: Testing remote data */ get_header(); <div class="main"> <div class="col-sm-12"> <header> <h2>Testing remote data</h2> </header> </div> <div class="container"> <div id="content" role="main"> <div class="col-sm-12"> <?php $url = 'http://www.bbc.co.uk/news/';// this url is only for example purposes $request = wp_remote_get( $url ); if(is_wp_error($request)) { return false; } else { $body = $request['body']; } echo $body; </div> …
Using wp_remote_get keeps pinging the API on every page load. Which increase the server resource. Is it possible to cache the response of the API store it using Transients and use it for next 5 minutes instead of keep pinging everytime? And After 5 Minutes it should send request again and rewrite the stored value. Here is my code for API Request. How to do this? I'm new to this. Help me please function display_api_response() { $api_url = "https://randletter2020.herokuapp.com"; $response …
I want to filter any HTTP request URI done through the HTTP API. Use cases: The WordPress update check goes to http://api.wordpress.org/core/version-check/1.6/, but https://api.wordpress.org/core/version-check/1.6/ works too, and I want to use this always. The new WordPress file is taken from http://wordpress.org/wordpress-3.4.2.zip, but https://wordpress.org/wordpress-3.4.2.zip works too. Sometimes I want to debug requests and redirect those temporary to a custom domain on my local server. Some plugins make requests to other servers, and I want to replace these requests when the external …
I have an external api which takes json body as payload. I am trying to send multiple parallel requests. So I am not using wp_remote_post() The wp_remote_post() version of my code works perfectly. Sending JSON payload using wp_remote_post() This works! $response = wp_remote_post($url, [ 'body' => json_encode($registrants), // requried keys [firstName, lastName, email] 'headers' => [ 'Authorization' => 'Bearer ' . $accessToken, 'Content-Type' => 'application/json; charset=utf-8' ], 'data_format' => 'body', 'timeout' => 10, ]); return json_decode(wp_remote_retrieve_body($response)); Now I am trying …
I am making a mobile app that links to a Wordpress site. There are a lot of unwanted data from the API response and it would be great if I could remove it. How could I do that without touching the PHP (I know nothing of it)? I am using React Native in the front end. Is there a good plugin or query params in the URL to solve this?
I dont want to use a REST API to publish to wordpress. I want to create a form on a wordpress page which will send a POST to an external REST API. Users will put in their information, and perhaps upload a file. When the press "submit" I want this information to be sent to a REST API on a different server (not wordpress). Are there any plugins that allow this? Has anyone done this? Of course, I might run …
i would like to remove the "link:" line added to the http headers since wordpress 4.4 here is a curl -I killcandida.org here is the output extract of the line that i would like to delete: Link: <http://killcandida.org/wp-json/>; rel="https://api.w.org/" Note that i don't talk here about html headers but http headers.
I have a http request to WP REST API that can resolve in a success or a failure status The success gets handled by WP_REST_Response, and if any error occurs this is handled by WP_Error, both returned if that's the case However, in both cases when I receive the server response I don't get any of the messages I've added public function myFunction($request = null) { $response = array(); $parameters = $request->get_json_params(); $error = new WP_Error(); if (success) { $response['code'] …
I'm building a mailchimp integration and they require a POST call with JSON code. No, I'm using this code that actually works: $data = wp_remote_post($url, array( 'headers' => array('Content-Type' => 'application/json; charset=utf-8'), 'body' => json_encode($array_with_parameters), 'method' => 'POST' )); But, it returns a PHP warning Warning: http_build_query(): Parameter 1 expected to be Array or Object. Incorrect value given in ../wp-includes/Requests/Transport/cURL.php on line 507 How to avoit it? I've tried to just use the plain array in 'body' index but MailChimp …
My plugin is throwing the error "Cannot use object of type WP_Error as array". The line in question is... $http = new WP_Http(); $response = $http->request( $url, array('timeout' => 20)); if( $response['response']['code'] != 200 ) { // THIS IS THE LINE return false; } $upload = wp_upload_bits( basename($url), null, $response['body'] ); So the problem is $response only has one result, so it's not an array? How do I fix this?