summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.php22
1 files changed, 22 insertions, 0 deletions
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;
+ }
}
?>