API credential
-
Hi, I’m testing the API but trouble with credentials.
When I hardcode the credentials inside of base64_encode(), it works fine.
However, when I save the credentials to the wp_config.php and call it to the file, it responds 401 error.
The code is like the following.1. Import the API from wp_config.php
echo WC_SHIP_KEY;
echo WC_SHIP_VALUE;
$credentials = WC_SHIP_KEY . ':' . WC_SHIP_VALUE;
$checking = is_string($credentials);
error_log(print_r('credential: ' . $credentials . ' and ' . $checking, true)); // it is a string with the correct value.2. The response part:
$response = wp_remote_post(
$url,
array(
'headers' => array(
'body' => $request_body
)
);Thank you,
- The topic ‘API credential’ is closed to new replies.