Why isn’t the URL the same for echo and for response in WordPress Remote

I’ve got this little shortcode

function starlight_count() {
$url = 'https://herokuapp.com/creditcount?contact_id=' . do_shortcode('[i4w_db__FirebaseID]');
$response = wp_remote_get( esc_url_raw( $url ) );
$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
$response_message = wp_remote_retrieve_response_message( $response );

ob_start(); ?>
<?php 
    echo $url;
echo $response_message;
    print_r($response); ?>
<?php
    return ob_get_clean();

}
add_shortcode( 'starlight-count', 'starlight_count' );

The first echo returns

https://herokuapp.com/creditcount?contact_id=-KhwKGq4EYNf0GCiw8Kn

But the actual call returns a 500 error, and is trying to request data from

[url] => https://herokuapp.com/creditcount?contact_id=%5Bi4w_db__FirebaseID%5D

Why isn’t it using the merged data URL?

Read more here: Why isn’t the URL the same for echo and for response in WordPress Remote

Leave a Reply

Your email address will not be published. Required fields are marked *