Skip to content

Commit 7aa5460

Browse files
authored
[FabBridge] Pull 100% discounted items via Fab API (RSS-Bridge#4584)
* [FabBridge] Pull 100% discounted items via Fab API * [FabBridge] Linter fixes
1 parent 98e0301 commit 7aa5460

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

bridges/FabBridge.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
class FabBridge extends BridgeAbstract
4+
{
5+
const NAME = 'Epic Games Fab.com';
6+
const URI = 'https://www.fab.com';
7+
const DESCRIPTION = 'Limited-Time Free Game Engine Assets';
8+
const MAINTAINER = 'thefranke';
9+
const CACHE_TIMEOUT = 86400;
10+
11+
public function collectData()
12+
{
13+
$url = static::URI . '/i/listings/search?is_discounted=1&is_free=1';
14+
15+
$header = [
16+
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0',
17+
'Accept: application/json, text/plain, */*',
18+
'Accept-Language: en',
19+
'Accept-Encoding: gzip, deflate, br, zstd',
20+
'Referer: ' . static::URI
21+
];
22+
23+
$json = getContents($url, $header);
24+
$json = json_decode($json);
25+
26+
foreach ($json->results as $item) {
27+
$thumbnail = $item->thumbnails[0]->mediaUrl;
28+
$itemurl = static::URI . '/listings/' . $item->uid;
29+
30+
$itemapiurl = static::URI . '/i/listings/' . $item->uid;
31+
$itemjson = getContents($itemapiurl, $header);
32+
$itemjson = json_decode($itemjson);
33+
34+
$this->items[] = [
35+
'title' => $item->title,
36+
'author' => $item->user->sellerName,
37+
'uri' => $itemurl,
38+
'timestamp' => strtotime($item->lastUpdatedAt),
39+
'content' => '<a href="' . $itemurl . '"><img src="' . $thumbnail . '"></a>' . $itemjson->description,
40+
];
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)