add several tags pictures

This commit is contained in:
Tykayn 2023-05-19 22:42:32 +02:00 committed by tykayn
parent 0315defb21
commit 788a9eaf48
3 changed files with 23 additions and 17 deletions

View File

@ -199,7 +199,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1684327639044</updated>
<workItem from="1684327640262" duration="8472000" />
<workItem from="1684327640262" duration="9102000" />
</task>
<servers />
</component>

View File

@ -8,29 +8,34 @@ use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
#[Route('/default', name: 'app_default')]
public function index(): Response
{
// TODO merge all these post list and deduplicate them
$url = "https://mastodon.cipherbliss.com/api/v1/timelines/public?remote=false&allow_local_only=true&only_media=true";
$url = "https://mastodon.cipherbliss.com/api/v1/timelines/tag/art";
$url = "https://mastodon.cipherbliss.com/api/v1/timelines/tag/mastoart";
// $url = "https://mastodon.cipherbliss.com/api/v1/timelines/public?remote=false&allow_local_only=true&only_media=true";
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $url );
//echo $response->getStatusCode(); // 200
// $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
$body = $response->getBody();
// $content = file_get_contents();
//
$decoded = json_decode($body->getContents());
$art = $this->getTagToots('art');
$mastoart = $this->getTagToots('mastoart');
$krita = $this->getTagToots('krita');
return $this->render('default/index.html.twig', [
'controller_name' => 'DefaultController',
'data' => $decoded,
'data' => array_merge($krita, $art, $mastoart),
]);
}
public function getTagToots($tagName)
{
$url = "https://mastodon.cipherbliss.com/api/v1/timelines/tag/$tagName";
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $url);
$body = $response->getBody();
return json_decode($body->getContents());
}
}

View File

@ -4,6 +4,9 @@
{% block body %}
<style>
body{
background: #313543;
}
.example-wrapper {
margin: 1em auto;
max-width: 1600px;
@ -71,8 +74,6 @@
</fieldset>
{# <h2>debug</h2>#}
{# {{ dump(data) }}#}
</div>
<style>
img {