admin管理员组文章数量:1134247
Hey am new to WP development, can any one tell me how to add request headers in wp_remote_get() or wp_remote_post() remote api calls.
I tried the following but didnt work
$response = wp_remote_get( add_query_arg( array(
'Affiliate-Id' => XXXXX,
'Affiliate-Token' => XXXXX
), $api_url ) , array( 'timeout' => 10));
Hey am new to WP development, can any one tell me how to add request headers in wp_remote_get() or wp_remote_post() remote api calls.
I tried the following but didnt work
$response = wp_remote_get( add_query_arg( array(
'Affiliate-Id' => XXXXX,
'Affiliate-Token' => XXXXX
), $api_url ) , array( 'timeout' => 10));
Share
Improve this question
asked Nov 28, 2015 at 10:30
Gopinath ShivaGopinath Shiva
1831 gold badge1 silver badge6 bronze badges
1 Answer
Reset to default 23If 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
)
));
本文标签: plugin developmentHow to add Request header in WordPress remote api calls
版权声明:本文标题:plugin development - How to add Request header in WordPress remote api calls 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736748013a1950882.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论