From 041247b46f831a05ec67280fe1695fb5a5644c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20L=2E=20=C5=A0ijanec?= Date: Wed, 6 May 2020 10:22:00 +0200 Subject: modflair dodan --- main.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.php b/main.php index d6c5649..0b869e6 100644 --- a/main.php +++ b/main.php @@ -73,6 +73,7 @@ Errors: private $cookiedir; // set at runtime, ker je get_curerent_user, v login() private $loginurl = "https://old.reddit.com/api/login/"; private $setflairurl = "https://old.reddit.com/api/selectflair"; + private $modflairurl = "https://old.reddit.com/api/flair"; public $modhash = ""; private $loggedin = false; public $ch = false; @@ -177,5 +178,26 @@ Errors: } return true; } + public function modflair($name, $text = "Preverjen Bežigrajčan!", $css_class = "preverjen-bezigrajcan-flair", $r = "bezigrad") { + if(!curl_getinfo($this->ch)) { + if (!$this->login()) { + return -2; + } + } + $ch = $this->ch; + curl_setopt($ch, CURLOPT_URL, $this->modflairurl); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'X-Modhash: '.$this->modhash, + 'X-ContactBotDeveloper: '."sijanecantonluka@gmail.com", + "X-UselessBot: true" + )); + curl_setopt($ch, CURLOPT_POSTFIELDS, 'name='.$name.'&r='.$r.'&css_class='.$css_class.'&text='.$text); + $request_output = curl_exec($ch); + if(curl_getinfo($ch, CURLINFO_RESPONSE_CODE) != 200) { + return false; + } + return true; + } } ?> -- cgit v1.2.3