How to add Request header in WordPress remote api calls

If you want to send Affiliate-Id and Affiliate-Token in headers then you need to pass them in the optional arguments of wp_remote_get function.

Example:

$response = wp_remote_get( $api_url ,
             array( 'timeout' => 10,
            'headers' => array( 'Affiliate-Id' => XXXXX,
                               'Affiliate-Token'=> XXXXX ) 
             ));

Leave a Comment