Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by edlefW-2 1 year, 7 months ago.

Assisted by: Bobby.

Author Posts
September 20, 2023 at 4:15 pm #14432311

edlefW-2

I am currently trying to register WPML on my freshly installed test site but receive "Unable to parse data from service response." due to a 403 reply from api.wpml.org

Temporarily i also disabled Firewall/ModSecurity on the server, but didn't help.

PHP and WP max memory values are both set to 256MB, libxml and mbstrings is activated.

Also tried to remove the site from WPML and re add it, but did not help.

Not sure what else i should try. Looked through this forum but couldn't find any working solution.

Would be great if someone could check 🙂
Site URL is given in Debug Info. You can ping it to get the IP.

September 20, 2023 at 10:36 pm #14433745

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Typically this would mean that your server is not allowing WPML to communicate with the site.

Removing the firewall temporarily is a good first step.

Please ensure to whitelist the IPs from the following URLs

hidden link
hidden link
hidden link
hidden link

Additionally, if you are possibly on AWS and using a load balancer make sure to review the configuration as the IP could be blacklisted .

September 21, 2023 at 12:00 pm #14438389

edlefW-2

Hi Bobby,

thanks for your reply. As said, there is nothing blocking traffic on my site.

A curl request via WP-CLI's eval like this worked just fine:

```
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'hidden link');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "action=site_key_validation&site_key=XXXXXX&site_url=hidden link");
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
```

Resulted with a correct answer like this - no 403:

```
O:8:"stdClass":6:{s:4:"info";a:1:{s:19:"site_key_validation";s:19:"Site key validation";}s:7:"success";s:7:"Success";s....
```

But running nearly the same via wp_remote_post() returns in error 403.

---------

After fumbling around i finally could solve it:

wp_remote_post() does not include any User-agent wheras curl() does per default.
api.wpml.org blocks request without User-agent, resulting in 403.

So the quite simple solution - no firewall settings or whatever - is:

```
function my_http_request_args($args) {
$args['user-agent'] = 'WordPress';
return $args;
}
add_filter('http_request_args', 'my_http_request_args');
```

The user-agent string can be whatever you like. It also worked with "something" or curl's default "curl/7.74.0".

---------

Remaining question:

Where does the user agent get lost in wordpress' codebase