Currently the Query monitor can show me the total page generation time, and the database query time, and the HTTP API call time.
However, Page Generation Time > Database Query Time + HTTP API call time.
For example, Page Generation Time is 0.7320s, Database Query Time is 0.0858s, HTTP API Call is None.
So there must be other things that take a major part of the Page Generation Time. How to find it?
]]>Almost five years after the report linked in [1], the HAL plugin doesn’t do HTTP requests the right way. It uses direct CURL calls while WP offers an official wrapper as described in [2].
do_common_curl_call() in wp-hal.php is wrong, CURL should not be used directly. For instance, the condition on WP_PROXY_* env vars in that function is buggy, not all proxies demand to be authenticated. The WP HTTP API takes care of all that stuff.
Please update your code, it will ease your work and please your users.
Thanks.
[1] https://www.ads-software.com/support/topic/hal-plugin-should-use-wp-s-http-api/
[2] https://developer.www.ads-software.com/plugins/http-api/
$args = array(
'timeout' => 30,
'httpversion' => '1.1',
'method' => 'GET',
'redirection' => 5,
'blocking' => true,
'sslverify'=> false,
'body' => array('api'=>'SOMEAPIKEY','url'=>'REQUIRED_BY_SERVICE','formal'=>'json'),
'headers' => array(
'Content-Type' => 'application/json'
),
'cookies' => array(),
);
wp_remote_get('https://MYSITE/api/',$args );
The same request works fine with CURL and even directly on browser.
CURL CODE:
$curl = curl_init();
$url = "https://MYSITE/api/?api=SOMEAPIKEY&url=REQUIRED_BY_SERVICE&format=json";
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_URL => $url
));
$Response = curl_exec($curl);
curl_close($curl);
return ($Response);
Anyone else facing issue when using wp_remote_get? Any ideas?
]]>The SEO Checklist plugin is launched!
There’s just one known bug at this time. The response time check will always say:
Your server didn’t take too long to respond.
Your server took s total to respond. Ideal response time is less than 2s.
As you can see, the total number of seconds doesn’t display. And because of that, that checklist item result is actually a false positive, since the time is unknown.
We have a fix for it using CURL, but because the WordPress plugin directory expects us to use WordPress’ HTTP API rather than CURL, we can’t use it. So we’ve reported the bug to WordPress core team, since we’ve narrowed it down to an issue in the API.
Hopefully it will be resolved soon.
– FlexiThemes Team
]]><?php
class The_Crawler {
public function __construct() { }
public function get_classifieds( $urls ) {
foreach($urls as $url) {
$response = wp_remote_get( $url );
print_r($response);
if ( is_array( $response ) && ! is_wp_error( $response ) ) {
$body = wp_remote_retrieve_body( $response );
$pattern = '<h3\sclass="title">.*</h3>';
preg_match( $pattern, $body, $titles );
print_r( $titles );
}
}
}
}
$urls = [
'https://www.kijiji.it/motori/moto-e-scooter/'
];
The_Crawler::get_classifieds( $urls );
]]>I have deactivated all plugins and have the same problem without anything but Jetpack activated. My host says that the back end of the site is connected to WordPress.com.
Site is sfsonic.com
]]>i just installed the plugin, and since then, i can’t add any widget anymore : when i go in the widget page, the UI where you normally drag’n’drop widget isn’t here ; clicking a widget doesn’t add it automatically anymore and moreover, i can’t manually add a widget going into the graphical personnalisation : i constantly get a link to add WowPi widget, but this doesn’t do anything at all.
I can’t add WoWPi widget, but can’t add any other widget too.
When i disable WoWPi, widgets return.
Can you help me ?
Thanks in advance, and cheers for all the good work !
]]>Plugin Version: 3.6.10 (API Version: 2.24.0)
thanks.
]]>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 WordPress had the HTTP API actually, but upon digging deeper I’ve realised it seems to be lacking a fair few things (documentation being one!)
Does the HTTP API support mutual authentication and SSL in any way? Specifically the mutual authentication part? (involving client certificates?) As this is a requirement of the API given the sensitive nature of the data.
All I can find is that it can support SSL but nothing to do with client certificates, and basic authentication.
I’m far from an expert in these things but I’m thinking I need to go down the pure PHP route using fsock/curl
Cheers!
]]>foreach ( $articles as $article_id ) {
$postarray = array(
'method' => 'POST',
'timeout' => 5,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => array(
'article_id' => $article_id
),
'cookies' => array()
);
$response = wp_remote_post($url, $postarray);
if ( is_wp_error($response) ) {
$error_message = $response->get_error_message();
echo $error_message;
} else {
// the rest of my code here
}
}
I’m working with 20+ posts per call. Everytime the loop finish, I get this error message:
Operation timed out after 5001 milliseconds with 0 bytes received
The strange thing is, the data are actually received and stored successfully on the designated $url
server.
Can anyone point me to the right direction, where should I look to avoid getting that error message?
Reference: wp_remote_post
]]>