cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Help

From: <trophy_at_tele2.se>
Date: Wed, 18 Jan 2012 16:39:55 +0100

Hi Please can you have a look at this it did work 2 month ago but now i just get Connection problem.
it get info to my signature i have on my site!
<?php
class IdsManager
{
private $login = "mail adress";
private $pw = "xxxxxxxxxx";
private $authId;
private $playerId;
private $authIdFile;
private $player;
public function __construct($playerName)
{
$this->authIdFile = fopen('ramdisk/authid', 'r');
$this->authId = fgets($this->authIdFile);
$this->retrieveAuthAndPlayerId($playerName);
$this->player = $playerName;
fclose($this->authIdFile);
}
private function connection()
{
$usermail = urlencode($this->login);
$password = urlencode($this->pw);
$post = "email=".$usermail."&password=".$password."&frm_action=login";
$ch = curl_init("http://secure.thehunter.com/submit/");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$header = curl_getinfo( $ch );
curl_close($ch);
unset($ch);
$securestr = explode("/", $header['url']);
$this->authId = $securestr[4];
fclose($this->authIdFile);
$this->authIdFile = fopen('./ramdisk/authid', 'w');
fseek($this->authIdFile, 0);
fputs($this->authIdFile, $this->authId);
}
private function retrieveAuthAndPlayerId($playerName)
{
if(empty($this->authId))
{
$this->connection();
}
$this->retrievePlayerIdFromSite($playerName);
if($this->playerId === 0)
{
$this->connection();
$this->retrievePlayerIdFromSite($playerName);
}
}
private function retrievePlayerIdFromSite($playerName)
{
$ch = curl_init("http://"/.$playerName.".thehunter.com/sid/".$this->authId."/site/statistics/");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
$header = curl_getinfo( $ch );
curl_close($ch);
unset($ch);
if(strpos($header['url'], "reason=no-profile-exists"))
{
$this->playerId = -1;
} elseif($header['url'] == "http://www.thehunter.com/pub/")
{
$this->playerId = 0;
} else {
$useridpos = strpos($response, "onclick=") + 12;
$this->playerId = substr($response, $useridpos, 11);
}
}
public function getPlayerId()
{
return $this->playerId;
}
public function getAuthId()
{
return $this->authId;
}
public function getPlayerName()
{
return $this->player;
}
public function isValid()
{
return (!empty($this->authId) && !empty($this->playerId) && $this->playerId != -1);
}
}
?>
Hope you can help me out with this....it did work 2 months ago!
Regards
Anders

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2012-01-18