Come aggiungere intestazioni di richiesta nelle chiamate API remote di WordPress
28 nov 2015, 12:30:59
Visualizzazioni: 16.9K
Voti: 8
Ciao, sono nuovo nello sviluppo per WordPress. Qualcuno può spiegarmi come aggiungere intestazioni di richiesta nelle chiamate API remote con wp_remote_get() o wp_remote_post()?
Ho provato questo metodo ma non ha funzionato:
$response = wp_remote_get( add_query_arg( array(
'Affiliate-Id' => XXXXX, // ID affiliato
'Affiliate-Token' => XXXXX // Token affiliato
), $api_url ) , array( 'timeout' => 10));

Gopinath Shiva
183
Tutte le risposte alla domanda
1
0
Se desideri inviare Affiliate-Id
e Affiliate-Token
negli header, devi passarli negli argomenti opzionali della funzione wp_remote_get
.
Esempio:
$response = wp_remote_get( $api_url , array(
'timeout' => 10,
'headers' => array(
'Affiliate-Id' => XXXXX,
'Affiliate-Token'=> XXXXX
)
));

WPTC-Troop
1.8K
28 nov 2015 13:05:04
Domande correlate
6
risposte
3
risposte