Skip to content

Commit

Permalink
set headers of remote_get so that the API works (#963)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
  • Loading branch information
cjyabraham committed Feb 3, 2025
1 parent a9418a1 commit 42f116c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@
$sched_event_api_key = get_post_meta( get_the_ID(), 'lfes_sched_event_api_key', true );

$url = 'https://' . $sched_event_id . '.sched.com/api/session/export?api_key=' . $sched_event_api_key . '&format=json&strip_html=Y&custom_data=Y';
$data = wp_remote_get( $url );
$data = wp_remote_get(
$url,
array(
'headers' => array( 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' ),
)
);

if ( is_wp_error( $data ) || ( wp_remote_retrieve_response_code( $data ) != 200 ) ) {
return false;
}

$sessions = json_decode( wp_remote_retrieve_body( $data ) );
$speakers = array();

Expand Down

0 comments on commit 42f116c

Please sign in to comment.