function connect() { http::setCookieJar('cookie.txt'); $this->homePage = http::get('http://mobile.bet365.com'); if ($this->homePage === FALSE || empty($this->homePage)) { return FALSE; } $this->sessionId = $this->getPropData('sessionId'); if ($this->sessionId === NULL || empty($this->sessionId)) { return FALSE; } echo "Session ID: " . $this->sessionId . "\n"; $this->powConnectionDetails = $this->getPropData('ConnectionDetails'); if ($this->powConnectionDetails === NULL || empty($this->powConnectionDetails)) { return FALSE; } if (!isset($this->powConnectionDetails[0]) || !isset($this->powConnectionDetails[0]['Host'])) { return FALSE; } echo "Pow HTTPS Host: {$this->powConnectionDetails[1]['Host']}:{$this->powConnectionDetails[1]['Port']}\n"; $this->clientRn = substr(str_shuffle("0123456789"), 0, 16); echo "Pow Random Number: {$this->clientRn}\n"; $requestPow = $this->powRequest(0, array('method: 0', 'transporttimeout: 20', 'type: F', 'topic: S_' . $this->sessionId)); var_dump($requestPow); if ($requestPow === FALSE || empty($requestPow)) { return FALSE; } $data = explode($this->readItConstants['FIELD_DELIM'], $requestPow); if (empty($data) || count($data) == 0 || count($data) == 1) { return FALSE; } echo "Constant: {$data[0]}\n"; echo "Pow Session Id: {$data[1]}\n"; $this->clientId = $data[1]; $sslStatus = urlencode($this->powConnectionDetails[1]['Host'] . ':' . $this->powConnectionDetails[1]['Port']); // Inform the main site of our connection http::post('https://mobile.bet365.com/pushstatus/logpushstatus.ashx?state=true', 'sslStatus=' . $sslStatus . '&connectionID=' . $this->clientId . '&uid=' . $this->clientRn . '&connectionStatus=0&stk=' . $this->sessionId, array('X-Requested-With: XMLHttpRequest', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8')); $requestPow = $this->powRequest(2, array('method: 1')); // Subscribe to the InPlay list $this->subscribe('OVInPlay_1_3//'); $requestPow = $this->powRequest(2, array('method: 1')); if (substr($requestPow, 0, 1) != "") { echo "Unexpected InPlay packet header"; return FALSE; } // Here we have some soccer data!!! wow!! $gameData = explode($this->readItConstants['RECORD_DELIM'], $requestPow); $gameData = explode("|", $gameData[count($gameData) - 1]); array_shift($gameData); // "F" $initialCL = $this->parameterizeLine($gameData[0]); if ($initialCL === FALSE) { return FALSE; } if ($initialCL['cmd'] != 'CL') { return FALSE; } if ($initialCL['params']['NA'] != 'Soccer') { return FALSE; } // It isn't soccer!!?? // I decided we don't need to know what damn league they're in, holy shit too much trouble $events = array(); // skip the initial CL (soccer) for ($i = 1; $i < count($gameData); $i++) { $lineData = $this->parameterizeLine($gameData[$i]); if ($lineData === FALSE) { continue; } // "EV" == EVENT // "CT" == COMPETITION_NAME // "PA" == PARTICIPANT // "MA" == MARKET // "CL" == CLASSIFICATION // "OR" == ORDER if ($lineData['cmd'] == 'EV') { //if($lineData['params']['ID'] != '1') // continue; array_push($events, $lineData['params']); } elseif ($lineData['cmd'] == 'CT') { if ($lineData['params']['NA'] == 'Coupons') { break; // It adds some kind of coupon stuff... what } } elseif ($lineData['cmd'] == 'CL') { break; // This isn't soccer m8 } } $requestPow = $this->powRequest(2, array('method: 1')); echo "Trying for ID: {$events[0]['ID']}\n"; $this->unsubscribe('OVInPlay_1_3//'); // It basically logs the data from the first soccer match found, if you want other matches loop through the array $soccerEvent = $this->getSoccerEventInformation($events[0]['ID']); var_dump($soccerEvent); return FALSE; }