37 lines
1 KiB
PHP
37 lines
1 KiB
PHP
<?php
|
|
|
|
require_once("vendor/autoload.php");
|
|
|
|
function get_api_client() {
|
|
global $conf;
|
|
|
|
$oAuth = new Colorfield\Mastodon\MastodonOAuth($conf["app"], $conf["instance"]);
|
|
$oAuth->config->setClientId($conf["client_id"]);
|
|
$oAuth->config->setClientSecret($conf["client_secret"]);
|
|
$oAuth->config->setBearer($conf["bearer"]);
|
|
$mastodonAPI = new Colorfield\Mastodon\MastodonAPI($oAuth->config);
|
|
return $mastodonAPI;
|
|
}
|
|
|
|
function get($url) {
|
|
global $http,$conf;
|
|
$ch=curl_init();
|
|
curl_setopt_array(
|
|
$ch,
|
|
[
|
|
/*
|
|
CURLOPT_COOKIEFILE => $conf["cookies"],
|
|
CURLOPT_COOKIEJAR => $conf["cookies"],
|
|
*/
|
|
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
|
CURLOPT_URL => $url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_TIMEOUT => 10,
|
|
]);
|
|
$result=curl_exec($ch);
|
|
$http=curl_getinfo($ch);
|
|
return $result;
|
|
}
|
|
|
|
|