You can check this:
$api_endpoint="https://url_to_API";
$api_args = array(
'method' => 'GET',
'headers' => array( 'Accept' => 'application/json', 'any' => 'other' )
);
$queries = array(
'your_query' => 1,
'another_query' => 5,
);
$api_endpoint = add_query_arg( $queries, $api_endpoint );
$response = wp_remote_request( $api_endpoint, $api_args );
$response_code = wp_remote_retrieve_response_code( $response )
$data = json_decode( wp_remote_retrieve_body( $response ), true );
Also you can access to the response code in this way: $response['response']['code'];
I didn’t try it but I have found this resources I think it can be usefull for you:
wp_remote_retrieve_response_code()
Hope it works for you 🙂
I am waiting to know if it has worked correctly for you, because I think is a very interesting issue.
Related Posts:
- REST-API: extend media-endpoint
- How to modify WCMP Rest API response?
- wp_remote_get() returns 403 while file_get_contents() does not
- is it possible to fetch data from a remote api while admin is writing a new post?
- Is it possible to create post in wordpress using postman?
- Loading external page template and enqueue script from plugin causes 403 forbidden error
- How to get Login Error messages on a custom template
- Multisite functions to communicate with individual site functions
- Force plugin to fail activation
- An Unexpected HTTP Error occurred during the API request
- Create or Update thousands of woocommerce products via PHP
- Keep user’s privileges on accessing contents in JSON response
- Accessing GET variable named ‘error’
- Best way to hook a custom url?
- How can I add an options page for my class based plugin?
- Sending WP posts to external API
- CSV file generation failing
- Python with wordpress plugin
- Limit post creation by role
- Set plugin-values when creating post via REST-API
- how to do login using woocommerce rest api From android
- AFNetworking incorrectly interpreted WP_Error
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- WordPress error: Options page Setting_ not found in the allowed options list
- Getting a Page via its post-name using WP REST API v2 and Postman
- WordPress REST API Plugin Development – Add Custom Endpoint
- Integrating boxtal PHP library into a custom WordPress Plugin
- How to create WordPress custom end point with multiple parameters?
- Custom API plugin to execute 3rd party API to retrieve data
- Seperate plugin and theme files
- wc_get_template_part doesnt display the content [duplicate]
- Escape commas in REST API
- Do i need to use a plugin for third party api integration?
- Getting all woocommerce products from REST API call in plugin
- add tags to wordpress post using REST API
- WordPress output data to another website and pull data
- One time call to external API in widget
- Showing how many times is plugin activated or deactivated
- Modifying server’s response to API endpoint
- wp_remote_post To external API multiple values with the same key
- Can’t access 3rd party API, code works on local server but not on wordpress
- How to get data from a private API and add it to wordpress pages
- How to use information from the database in the front-end?
- wp rest api (v2) filter not working (404 error – rest_no_route)
- How do I create a state of “don’t assign anything to variable” if WP_Error throws an error?
- what is the best way to create a premium plugin while also protecting your code
- create web service for android app using wordpress website
- A more elegant way to handle notices/warnings
- API Functions to Register and Show WordPress List Tables
- Extend WordPress REST API with Scheme Pro Plugin
- The plugin generated xxx characters of unexpected output during activation
- wordpress Ajax success doesn’t return the value
- move setting data from wordpress api to codestar freamwork
- Accessing Correct Database to Create REST API Endpoint
- REST API – filters not working inside plugin class
- Error 400 Invalid “products[1].productId” Kinguin [closed]
- i need to resive data external api and show user
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- Best way to initiate a class in a WP plugin?
- How do you debug plugins?
- How to structure a plugin
- What’s the preferred method of writing AJAX-enabled plugins?
- Add multiple plugin directories
- What are the differences between WPINC and ABSPATH?
- How to add a shortcode button to the TinyMCE editor?
- Where do I put the code snippets I found here or somewhere else on the web?
- What Plugins Demonstrate Great WP Plugin Development? [closed]
- is_plugin_active function doesn’t exist
- Delete WordPress plugin Repository
- Custom pages with plugin
- How to change a user’s password programatically
- How to catch/what to do with a WP Error Object
- WP Rest API: details of latest post including featured media url in one request?
- Who are the most trusted plugin developers? [closed]
- How can I find plugins’ slug?
- An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration
- List all sidebar names?
- What are the common security flaws I need to look for? [closed]
- I Want to Get A Plugin Version Number Dynamically
- Get plugin_dir_url() from one level deep within plugin
- Pass PHP variable to javascript
- Where is the best place to use add_filter
- Can a developer adopt a plugin marked as “not updated in over 2 years”?
- Conditionally enqueue a widget’s script/stylesheet in HEAD (only when present on page!)
- How to implement WordPress plugin update that modifies the database?
- What is difference between get_bloginfo(‘url’) and get_site_url()?
- Custom media upload content for inserting custom post shortcode
- Stop a plugin in the activation process when a certain WP version is not met then show error message in admin_notices action hook
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- How to Add an Index to Plugin Database table
- Does the number of downloads displayed for a plug-in in the WordPress.org plug-in directory include automatic updates?
- how to create child WordPress plugin
- What are the best practices for updating?
- Redesigning Custom Post Type “Add New” page
- Building a custom REST API
- How to safely sanitize a textarea which takes full HTML input
- Is there a plugin that will override the “Error establishing a database connection” message? [closed]
- How to Remove Certain Screen Options and Meta Boxes from add/edit post type?
- Making my plugin multi-site compatible
- Why activate_plugin is not working in register_activation_hook