Questions tagged [http-api]
The http-api tag has no usage guidance.
76
questions
0
votes
1
answer
50
views
Send and receive emails with wp_mail() for WP User (like Mailserver)
I have developed an app, which is connected to my WordPress Backend. I would like to provide my User (WP User) an email function to send and receive mails without using a dedicated email account (...
1
vote
1
answer
144
views
wp_http remote request not respecting timeout
I am trying to test for timeout scenarios for my API requests using WP_Http::request() by passing a very short timeout argument (a minimal fraction of a second). After my API requests continued to ...
0
votes
1
answer
387
views
WordPress getting data from external API
I am trying to create a Plugin that does the following jobs:
Authenticate the user to get Bearer token 'access_token'
Get data from API and store in Database
I have checked all the APIs and ...
2
votes
1
answer
362
views
Why is this specific API request failing when sending via wp_remote_post?
I'm pulling my hair out trying to make a POST request to an API endpoint using wp_remote_post.
The API needs a request with content-type multipart/mixed but WordPress doesn't seem to play nicely with ...
1
vote
0
answers
66
views
Need help creating asynchronous data scraper in WordPress
I need some help on a data scraping script I've been working on. I want to create a script through which content can be extracted from a page.
I fetched the page via wp_remote_get() and ...
1
vote
1
answer
1k
views
How to use the HTTP API (wp_remote_get) instead of cURL?
I'm running into a problemen while trying to change my cURL request into a request using the HTTP API.
Below code is my (old) cURL request. Here I'm getting some contents from an external URL. This is ...
4
votes
1
answer
966
views
External HTTP API calls slowing down Wordpress admin [closed]
By using Query Monitor I'm finding that virtually every page load within Wordpress admin results in 15-25 server-side HTTP API calls being made. Most take less than 0.1s, but there's 5 or more that ...
1
vote
0
answers
217
views
WP Remote Request not returning all of content via request
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 ...
0
votes
1
answer
983
views
Properly loop through and paginate page on each function call
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 ...
1
vote
1
answer
1k
views
How to convert this cURL to wp_remote_get?
I want to convert curl to wp_remote_get.
$url = 'https://accounts.google.com/o/oauth2/token';
$curl_post = 'client_id=' . $client_id . '&redirect_uri=' . $redirect_uri . '&...
0
votes
1
answer
3k
views
Call external API in wordpress based on user input
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 ...
0
votes
1
answer
398
views
wp_remote_post empty $_POST
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":{},&...
1
vote
1
answer
687
views
Cache WP remote_get HTTP Response using Transients
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 ...
0
votes
0
answers
1k
views
Remove unwanted fields from WP API response
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 ...
1
vote
2
answers
823
views
Sending JSON Payload using Request::request_multiple()
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.
...
0
votes
1
answer
571
views
How to receive JSON payload from a digital device
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 ...
1
vote
1
answer
2k
views
Return WP_Error as WP_REST_Response
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 ...
0
votes
2
answers
795
views
WP_Http response throws "Cannot use object of type WP_Error as array"
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( ...
1
vote
0
answers
1k
views
wp_remote_request header error even though working properly with cURL
I'm trying to make calls to a JSON API inside my wordpress theme.
I tried with the cURL option, making a custom function and things works as it should but I wanted to use the built-in wordpress ...
0
votes
1
answer
3k
views
Send a get request to wordpress
I want to have a url like this:
http://example.com?user_id=23&entry_id=34$nonce=4j54hgc465
When a user clicks on this link, I want to do something with this information like update the user or ...
2
votes
1
answer
438
views
Allow download_url for lan addresses
I'm hosting a wp site on my own server (at home) and I would like to use wp cli to import media from my own computer.
On my computer, I have a web server and I asks to wp-cli to import media from "...
0
votes
2
answers
542
views
Why does WP HTTP API switch the method (POST/PURGE) to GET when redirecting (302)?
I discovered after much painful debugging that requests to the the WP HTTP API (in this case, though wp_remote_request()) always ended up as GET method after being redirected, even if the method was ...
5
votes
3
answers
5k
views
Difference between wp_remote_post and wp_safe_remote_post
The documentation for wp_remote_post says
In many cases you may be better served with wp_safe_remote_post
Looking at the source code, the only line that's different between the two is that ...
1
vote
1
answer
909
views
wp remote post getting a 404 error code
$info = array(
'values' => array(
'email' => '[email protected]',
'firstname' => "firstname",
'lastname' => "lastname",
'source' => "WEB",
),
);
$infoo=json_encode($...
1
vote
0
answers
187
views
How to make a implement queue for scheduling tasks in WordPress?
Is it possible to implement some queuing mechanism for task scheduling? In my plugin, I want to run a task triggered by cron for 5 seconds and if not complete, save the state and call another Async ...
7
votes
1
answer
5k
views
How to run multiple Async HTTP requests in Wordpress?
In my plugin, I want to call 10 or more HTTP requests asynchronously in WordPress so that I need not wait for the response of anyone. Is there any way in Wordpress that supports this and also ...
0
votes
1
answer
630
views
Using WP_Http to post data to Webservice without blocking caller script
I've been using WP_Http to post data to a (third-party) webservice.
Their webservice is slow like hell so I can't wait for their webservice's answer.
I have tried using the parameter blocking = ...
0
votes
1
answer
1k
views
Save external API calls in WordPress
I coded a WordPress page on which users can submit their name. After pressing submit, it will send an API request to an external API, which returns information about their name. This is a simple ...
1
vote
0
answers
1k
views
XML-code sent via the POST method to the URL (API) [closed]
I am building a webshop for a client who makes use of drop shipping service. The customer can place the order on the website and the order will be send to the dropshipper automatically. This is done ...
2
votes
1
answer
1k
views
How to set charset for wp_remote_post request?
I'm using wp_remote_post() on a project and it works great. But seems like the server on which I need to make the POST request is a Windows (ISS) server. So the third-party service that provides this ...
0
votes
1
answer
715
views
Creating custom URLs with template to fetch external JSON
Hi guys hope you can help.
So I have a WP site and an external JSON enpoint (NOT from another WP) and what I want to achieve is to create dynamic "fake" URLs inside wordpress like: example.com/...
2
votes
1
answer
1k
views
How do I get URL from WP_HTTP object?
I'm using wp_remote_post:
$test = wp_remote_post($environment_url, $args2 );
$test2 = $test['http_response'];
So what I want to do is get the value of URL but I believe the object is ...
4
votes
2
answers
5k
views
How to consume and display external data in WordPress from another website
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
*/
...
2
votes
2
answers
663
views
How to duplicate a curl XML request using HTTP API?
I am working on a plugin that posts an XML request to a vendor's shipping API to get shipping quotes. The XML is stored in a string called $xml. I can post the XML request successfully with curl using ...
27
votes
1
answer
42k
views
Sending JSON string through wp_remote_post()
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('...
0
votes
1
answer
2k
views
How to set a header in wp_safe_remote_get()?
Previously I am using the below code. Now I need to change this code and replace file_get_contents() with wp_safe_remote_get(). I need to know how to set 'header' => "Accept: application/json" ...
2
votes
1
answer
505
views
Extending Wordpress REST API
I'm trying to create an API where external clients can authenticate users and reset their password through a REST API. I've already seen this: External WordPress API. However, it looks like this is ...
10
votes
1
answer
10k
views
How to remove rest api link: in http headers?
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: &...
0
votes
1
answer
70
views
Turn twitter-urls into list timelines?
I know there's the oEmbed ability to embed a specific tweet, as described in their documentation... but is there any way to simply get the latest in a particular twitter feed, without setting up an ...
8
votes
1
answer
694
views
Mutual Authentiction on HTTPS with Wordpress HTTP API?
I'm currently building a prototype to post data from Wordpress to a Rightmove RESTful JSON API (a rental/property website in the UK - specifically the Real Time Datafeed)
Was pretty impressed that ...
1
vote
1
answer
3k
views
How to make Http Request to a php file present in plugin directory of wordpress
I'am new to wordpress plugin development and I'am developing a plugin (say myplugin) and I'am stuck in following problem.
I had kept this plugin in mywebsite/wp-content/plugin/myplugin
Inside ...
0
votes
1
answer
965
views
cURL vs WP_Http for safety?
when it comes to cross domain request for personal information such as user information it must be done on the back-ed for safety reasons. I'm am new to cURL but it has been pointed out to not use it ...
0
votes
1
answer
2k
views
Proper context for wp_remote_post()
I would like to use wp_remote_post() within a function to send an HTTP Post Request to a php script inside a plug-in.
I'm successfully posting to the plug-in script, but having trouble with the ...
6
votes
2
answers
5k
views
HTTP digest authentication using wp_remote_get
I am able to implement http basic auth in wp_remote_get using the following code
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $...
1
vote
1
answer
364
views
How do I create an rssfeed from the contents on this page?
So. I created a gmail rss feed with php that I placed in a custom page. I used this snippet:
function checkGmail($username, $password)
{
$url = "https://mail.google.com/mail/feed/atom";
$curl ...
0
votes
1
answer
129
views
How to add code to HTTP header
I have a code that I need to insert into the HTTP header of my website to make Google Fonts work again.
My Google Fonts aren't rendering on one of my simple websites (http://ceobusinessalliance.com). ...
1
vote
1
answer
2k
views
WP http XML response HTML encoding and image display problems
This is my very first WP plugin. Theres probably going to be more than one question here and they're all related so I'm going to ask all here.
Working test here
Tracking number to use: lc0614061377
...
6
votes
2
answers
18k
views
Error timed out with succesfull wp_remote_post
What I'm trying to do: Passing POST data by using wp_remote_post.
foreach ( $articles as $article_id ) {
$postarray = array(
'method' => 'POST',
'timeout' => 5,
'...
10
votes
5
answers
12k
views
How do I mock HTTP requests for PHPUnit?
I'm writing a plugin that makes requests to the Facebook graph API. As I don't want my unit tests to actually make these requests, how would I overcome this? My method calls both wp_remote_get and ...
0
votes
0
answers
171
views
Get full page HTML for a non-public Wordpress page
How can I write a function that will return the full rendered HTML of a non-public URL on my Wordpress site—a URL that you must be logged in to see, such as a draft? Not just the post content, but the ...