70 行
1.8 KiB
PHP
70 行
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Peertube;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Engine;
|
|
// use Illuminate\Support\Facades\Log;
|
|
|
|
class Common extends Engine {
|
|
private $engine;
|
|
|
|
public function __construct () {
|
|
// $this->getLocal();
|
|
// $this->getMe();
|
|
// $this->getNotify();
|
|
$this->engine = new Engine;
|
|
}
|
|
|
|
public function getLocal () {
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/oauth-clients/local');
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$get = curl_exec($ch);
|
|
$err = curl_error($ch);
|
|
curl_close($ch);
|
|
|
|
if (!$get) return $err;
|
|
$get = json_decode($get);
|
|
if (isset($get->status) && $get->status == 404) return [];
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getMe () {
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/users/me');
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$get = curl_exec($ch);
|
|
$err = curl_error($ch);
|
|
curl_close($ch);
|
|
|
|
if (!$get) return $err;
|
|
$get = json_decode($get);
|
|
if (isset($get->status) && $get->status == 404) return [];
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getNotify () {
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/users/me/notifications?start=0&count=0&unread=true');
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$get = curl_exec($ch);
|
|
$err = curl_error($ch);
|
|
curl_close($ch);
|
|
|
|
if (!$get) return $err;
|
|
$get = json_decode($get);
|
|
if (isset($get->status) && $get->status == 404) return [];
|
|
|
|
return $get;
|
|
}
|
|
}
|