Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP - Atelier 801 Forum Request
<?php
class atelier801Forums {
public $session, $hiddenKey;
function __construct($user, $pass){
$this->session = new Requests_Session("http://atelier801.com/");
$this->setHeaders();
$this->GET("http://atelier801.com/forums");
$fields = array(
"id" => $user,
"pass" => $pass,
"rester_connecter" => "on"
);
$this->POST("identification", $fields);
}
public function GET($url, $ref = "http://atelier801.com/forums"){
$this->session->headers["Referer"] = $ref;
$response = $this->session->get($url);
$this->getHiddenKey($response->body);
return $response;
}
public function POST($url, $args, $ref = "http://atelier801.com/forums"){
$this->session->headers["Referer"] = $ref;
$args[$this->hiddenKey[1]] = $this->hiddenKey[2];
$response = $this->session->post("http://atelier801.com/".$url, array(), $args);
return $response;
}
private function getHiddenKey($body){
preg_match('/<input type="hidden" name="([a-zA-Z0-9 -]{1,10})" value="([a-zA-Z0-9 -]{1,50})"/', $body, $matches);
$this->hiddenKey = $matches;
}
private function setHeaders(){
$this->session->headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
$this->session->headers["Accept-Encoding"] = "gzip, deflate, sdch";
$this->session->headers["Accept-Language"] = "pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4";
$this->session->headers["Cache-Control"] = "max-age=0";
$this->session->headers["Connection"] = "keep-alive";
$this->session->headers["Host"] = "atelier801.com";
$this->session->headers["Referer"] = "http://atelier801.com/forums";
$this->session->headers["Upgrade-Insecure-Requests"] = "1";
$this->session->headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.