From dc5ab24a378964a190d50e54be8781690c94760c Mon Sep 17 00:00:00 2001 From: DanielH <77276428+danhaber@users.noreply.github.com> Date: Thu, 23 Mar 2023 00:28:02 +0200 Subject: [PATCH 1/3] Update phpFlickr.php to include User-Agent Flickr just announced they will be requiring a User-Agent in the header of all API calls. See: https://github.com/dan-coulter/phpflickr/issues/90 --- phpFlickr.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpFlickr.php b/phpFlickr.php index 57dcf9b..7f3aedf 100644 --- a/phpFlickr.php +++ b/phpFlickr.php @@ -225,6 +225,7 @@ function post ($data, $type = null) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_USERAGENT, 'User-Agent: PHP_Flickr/3.11'); $response = curl_exec($curl); curl_close($curl); } else { From 4761ce299f4085032656dd00b5d9adfdd9fb7be8 Mon Sep 17 00:00:00 2001 From: DanielH <77276428+danhaber@users.noreply.github.com> Date: Thu, 23 Mar 2023 00:37:24 +0200 Subject: [PATCH 2/3] Add User-Agent to sockets as well --- phpFlickr.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpFlickr.php b/phpFlickr.php index 7f3aedf..6eced3a 100644 --- a/phpFlickr.php +++ b/phpFlickr.php @@ -241,6 +241,7 @@ function post ($data, $type = null) { } fputs ($fp,'POST ' . $matches[2] . " HTTP/1.1\n"); fputs ($fp,'Host: ' . $matches[1] . "\n"); + fputs ($fp, 'User-Agent: PHP_Flickr/3.11' . "\n"); fputs ($fp,"Content-type: application/x-www-form-urlencoded\n"); fputs ($fp,"Content-length: ".strlen($data)."\n"); fputs ($fp,"Connection: close\r\n\r\n"); From 3fe21903f1d4672b86b7e99f33b4d55df9af5047 Mon Sep 17 00:00:00 2001 From: DanielH <77276428+danhaber@users.noreply.github.com> Date: Thu, 23 Mar 2023 08:45:12 +0200 Subject: [PATCH 3/3] Remove User-Agent prefix from CURLOPT_USERAGENT Thanks to SamWilson for pointing that out. https://github.com/dan-coulter/phpflickr/issues/90#issuecomment-1480434205 --- phpFlickr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpFlickr.php b/phpFlickr.php index 6eced3a..dfaced8 100644 --- a/phpFlickr.php +++ b/phpFlickr.php @@ -225,7 +225,7 @@ function post ($data, $type = null) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_USERAGENT, 'User-Agent: PHP_Flickr/3.11'); + curl_setopt($curl, CURLOPT_USERAGENT, 'PHP_Flickr/3.11'); $response = curl_exec($curl); curl_close($curl); } else {