Add user agent to ApiFetcher

This commit is contained in:
Skylar Ittner 2023-02-28 20:34:42 -07:00
parent 8783d52cc7
commit d851807935
2 changed files with 13 additions and 9 deletions

View File

@ -49,7 +49,11 @@ class ApiFetcher {
// Make the actual URL that will be requested // Make the actual URL that will be requested
$requesturl = $url . "?" . implode("&", $urlparams); $requesturl = $url . "?" . implode("&", $urlparams);
$content = file_get_contents($requesturl); $content = file_get_contents($requesturl, false, stream_context_create([
"http" => [
"header" => "User-Agent: Mozilla/5.0 (PHP) See source.netsyms.com"
]
]));
// Only insert into db if it didn't fail horribly // Only insert into db if it didn't fail horribly
if ($content !== FALSE) { if ($content !== FALSE) {

View File

@ -21,14 +21,14 @@ class NewsCategory {
const SOCIAL = 128; const SOCIAL = 128;
const CATEGORIES = [ const CATEGORIES = [
self::BUSINESS => "Business", self::BUSINESS => "business",
self::ENTERTAINMENT => "Entertainment", self::ENTERTAINMENT => "entertainment",
self::GENERAL => "General", self::GENERAL => "general",
self::HEALTH => "Health", self::HEALTH => "health",
self::SCIENCE => "Science", self::SCIENCE => "science",
self::SPORTS => "Sports", self::SPORTS => "sports",
self::TECHNOLOGY => "Technology", self::TECHNOLOGY => "technology",
self::SOCIAL => "Social" self::SOCIAL => "social"
]; ];
public function __construct(int $category) { public function __construct(int $category) {