diff options
author | Anton L. Šijanec <anton@sijanec.eu> | 2020-05-06 10:22:00 +0200 |
---|---|---|
committer | Anton L. Šijanec <anton@sijanec.eu> | 2020-05-06 10:22:00 +0200 |
commit | 041247b46f831a05ec67280fe1695fb5a5644c84 (patch) | |
tree | 739e422cf029823c43981c6cfaaaf25b2c70ab33 | |
parent | added corinavitus counter (diff) | |
download | oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.tar oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.tar.gz oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.tar.bz2 oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.tar.lz oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.tar.xz oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.tar.zst oldredditclient-041247b46f831a05ec67280fe1695fb5a5644c84.zip |
-rw-r--r-- | main.php | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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; + } } ?> |