From c500a3d9d88ec1bf4b80b8e6843acdcb3779119c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Rodrigo=20Cal=C3=B3gero?= Date: Tue, 6 Sep 2022 03:07:27 -0300 Subject: [PATCH 1/2] Added default user-agent (#16) Shopify doesn't accept a CURL without `CURLOPT_USERAGENT` option, it returns `403 Forbidden` instead. --- src/Feed.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Feed.php b/src/Feed.php index 8fcba58..3a59c27 100644 --- a/src/Feed.php +++ b/src/Feed.php @@ -218,6 +218,7 @@ private static function httpRequest($url, $user, $pass) curl_setopt($curl, CURLOPT_TIMEOUT, 20); curl_setopt($curl, CURLOPT_ENCODING, ''); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // no echo, just return result + curl_setopt($curl, CURLOPT_USERAGENT, ''); if (!ini_get('open_basedir')) { curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // sometime is useful :) } From 2b22c961ddf26e5d884c6b5d36265013b26a9911 Mon Sep 17 00:00:00 2001 From: Abdelkarim CHAMLAL Date: Thu, 24 Nov 2022 12:52:50 +0100 Subject: [PATCH 2/2] ipv4 first approach --- src/Feed.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Feed.php b/src/Feed.php index 3a59c27..c00c761 100644 --- a/src/Feed.php +++ b/src/Feed.php @@ -216,6 +216,11 @@ private static function httpRequest($url, $user, $pass) curl_setopt($curl, CURLOPT_USERAGENT, self::$userAgent); // some feeds require a user agent curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_TIMEOUT, 20); + + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { + curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + } + curl_setopt($curl, CURLOPT_ENCODING, ''); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // no echo, just return result curl_setopt($curl, CURLOPT_USERAGENT, '');