From 7160e5b26669ffb19ddebd76df94f2e3739ce94f Mon Sep 17 00:00:00 2001 From: Catalin Date: Thu, 7 Sep 2023 12:16:05 +0300 Subject: [PATCH 1/4] HDX-9159 add cookies and headers for twitter feed retrieval --- build/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/functions.php b/build/functions.php index afe663a..3b2caee 100644 --- a/build/functions.php +++ b/build/functions.php @@ -447,7 +447,9 @@ function get_latest_tweets() { $limit = 5; $url = 'https://syndication.twitter.com/srv/timeline-profile/screen-name/'.$username.'?limit='.$limit.'&omit_script=1&chrome=noheader nofooter noborders noscrollbar transparent&dnt=true'; - $response = wp_remote_get(esc_url_raw($url)); + $headers = ['User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36']; + $cookies = [new WP_Http_Cookie(['name' => 'auth_token', 'value' => '3d74f09d42f371dde6ce63cc7729049ba61ba01f'])]; + $response = wp_remote_get(esc_url_raw($url), ['headers' => $headers, 'cookies' => $cookies]); if(is_array($response) && !is_wp_error($response)) { preg_match("/