-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
23 lines (16 loc) · 756 Bytes
/
index.php
File metadata and controls
23 lines (16 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
use MyShowsRpc\ApiNews;
use MyShowsRpc\RpcClient;
use App\News\NewsManager;
include_once 'vendor/autoload.php';
$rpcClient = RpcClient::GetInstance( 'https://api.myshows.me/v3/rpc/' );
$newsManager = new NewsManager( $rpcClient );
$title = $newsManager->GetNewsTitleById( 1 );
echo $title ."\n"; // will be "Russian Doll. Жизни матрешки"
$title = $newsManager->GetNewsTitleById( -1 );
echo $title ."\n"; // will be "News with newsId=-1 is not found", because we catch rpc error exception in our manager.
/** @var ApiNews[] $news */
$news = $newsManager->GetLastThreeNews();
foreach ( $news as $item ) {
echo $item->title ."\n"; // will output last 3 news titles.
}