Maybe someone will need:
I found this code in cf7-to-api/includes/class-cf7-api-admin.php
$args = array(
'timeout' => 5,
'redirection' => 5,
'httpversion' => '1.0',
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
'blocking' => true,
'headers' => array(),
'cookies' => array(),
'body' => null,
'compress' => false,
'decompress' => true,
'sslverify' => true,
'stream' => false,
'filename' => null
);
I set
'headers' => array()
on:
'headers' => array(htmlspecialchars("authorization: Token <your_64_char_api_key>"),"content-type: application/json"),
-
This reply was modified 8 years, 4 months ago by
kmadenski.
This is not a recommended approach because your changes will be deleted once you update the plugin
You can add the following to your functions.php file
add_filter( ‘qs_cf7_api_get_args’ , ‘add_http_header’ , 10 , 1);
function add_http_header( $args ){
$args[‘headers’] = array(
htmlspecialchars(“authorization: Token
<your_64_char_api_key>”),”content-type: application/json”);
return $args;
}
I’m trying to use this snippet and am having trouble. Am required to use a Bearer token for this particular API, and still getting 401 errors no matter what I do. Is there an easier way to access the header for an API request sent from this plugin?
I too am trying to use the snippet in my functions.php and it makes the website a blank page.