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
$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
if ($content !== FALSE) {

View File

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