wp_remote_get
return array of results containing keys body
, headers
, response
etc depending on arguments.
And json_decode
only accept JSON string. So correct your code in this way
//return if not an error
if ( ! is_wp_error( $response ) ) { //decode and return
return json_decode( wp_remote_retrieve_body( $response ) );
}
Related Posts:
- WP Rest API: details of latest post including featured media url in one request?
- Building a custom REST API
- WP JSON REST API (Ryan McCue) how to query posts with specific meta data with ‘AND’ relation?
- Keep user’s privileges on accessing contents in JSON response
- I’m receiving the following error using the below code: Uncaught Error: Cannot use object of type WP_REST_Response as array
- WordPress output data to another website and pull data
- CRUD from WordPress to Business Central 365 through OData REST API
- WordPress PHP error getting posts from another wordpress blog
- WP Rest API v2.0 user profile update issue
- how to know that a wordpress plugin support using API?
- Prevent plugin from intruding on wp-json posts api
- REST route from a plugin not working if WordPress is installed in a subdirectory
- Plugin retrieving results even after uninstallation
- Getting a Page via its post-name using WP REST API v2 and Postman
- WordPress REST API Plugin Development – Add Custom Endpoint
- Create WordPress posts from JSON array using plugin in admin
- Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin
- How to create WordPress custom end point with multiple parameters?
- How to execute plugin and theme updates from a web hook / endpoint?
- How do I make reusable content blocks for header and footer when using WordPress headless with another front-end?
- REST API can’t get the response manually
- How to integrate together a website currently hosted WordPress.com and a custom web application currently hosted on Azure?
- Custom API plugin to execute 3rd party API to retrieve data
- URL rewrite with external JSON query
- WordPress /users/me endpoint request forbidden
- Call Ajax URL in Plugin
- Seperate plugin and theme files
- Change Dashboard URL from wp-admin to wp-admin/index.php
- WordPress Media Library Folders + Custom Linux Server Hosting
- wc_get_template_part doesnt display the content [duplicate]
- WordPress REST API: Query media files attached to a custom post type
- Upload Javascript and json webpage to wordpress
- How to add a PW Gift Card to a Woocommerce Order request API?
- How to send SMS notification to customer after click on submit?
- How to send the featured image of a post to an API?
- Escape commas in REST API
- In a plugin, How to update a json file using ajax
- How to authenticate via API to allow writes/updates
- Do i need to use a plugin for third party api integration?
- Adding Custom Endpoint in WordPress Rest API
- One WooCommerce Store to multi distributor sites
- How to use Datatable with Ajax when creating plugin on WordPress?
- Custom REST API POST Endpoint Not Working, 404 Error
- Getting all woocommerce products from REST API call in plugin
- is it possible to fetch data from a remote api while admin is writing a new post?
- add tags to wordpress post using REST API
- Hide response returned from WordPress REST API call
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- How achive serving multiple concurrent Ajax / Rest calls in plugin?
- WP Rest Api GET method restriction on route, but POST method also works
- Showing how many times is plugin activated or deactivated
- Modifying server’s response to API endpoint
- Can’t access 3rd party API, code works on local server but not on wordpress
- Is it possible to custom set query for a WordPress REST API response?
- How can I add a permissions callback to the REST API index pages?
- How to get data from a private API and add it to wordpress pages
- Plugin json page
- Fetching users data from REST API
- Consume legacy rest api dependent upon WP API plugin
- wp rest api (v2) filter not working (404 error – rest_no_route)
- API page return Header 500 but Work
- custom REST endpoint not passing body of POST request to callback
- Fetching WP.me shortlinks for posts using WP Rest API
- Upload image to wordpress using ionic/cordova with WP REST API V2
- Populate select option with JSON file
- Sending post data over REST API, how to parse shortcodes in post_content?
- How to do rest APi with wordpress
- Ajax specific template not loading in replacement of index.php
- JSON Feed on my wordpress Blog
- Extend WordPress REST API with Scheme Pro Plugin
- Plugin Admin Page Ajax-Admin call returning 0, URL set correctly. Implemented localized scripts but did not fix it
- wordpress plugin JSON API search within specific category
- Output pure JSON wordpress
- Undefined property: stdClass::$ AND Trying to get property ‘name’ of non-object Error in plugin
- wordpress Ajax success doesn’t return the value
- How can I send api calls from my plugin?
- Filter custom post type returned from REST api
- My wp_update_nav_menu action is firing twice
- WordPress REST API Visual Composer Shortcodes
- Update post meta Rest Api
- Social login authentication via wordpress rest api
- Is option_active_plugins actually doing anything useful?
- WordPress REST API filter on blank custom ACF
- WooCommerce REST API aborts connection [closed]
- Is it possible to create post in wordpress using postman?
- How to update a lot of posts on my WP site with additional content?
- how to update WordPress plugins from external website with nodejs?
- Stop the user if login from the cookies
- Block Root REST API Route using custom &/or iThemes
- Accessing Correct Database to Create REST API Endpoint
- Is it a good idea to restrict the REST API
- REST API – filters not working inside plugin class
- Error 400 Invalid “products[1].productId” Kinguin [closed]
- ImageMagick on wordpress 6.5.5 for Linux Alma 8 success but which no magick
- i need to resive data external api and show user
- Can The REST API be used to create/edit plugins and themes?
- How prevent STDOUT of Plugin_Upgrader->upgrade(…)?
- Get list of outdated plugins in the rest api?
- Fetch the CSS of a resource (page/post/etc)
- WordPress keeps showing 403 error on console when updating post or adding new application password