Ejemplo n.º 1
0
 public function login($username, $password)
 {
     $this->logger->writeln('Login zu Subcentral');
     $this->req = new URLRequest('http://www.subcentral.de/index.php?form=UserLogin', $this->cookieJar);
     $this->cookieJar = $this->req->getCookieJar();
     $this->req->setType('POST');
     $this->req->setOption(CURLOPT_COOKIESESSION, TRUE);
     // beginne neue session
     $this->req->setOption(CURLOPT_COOKIEFILE, FALSE);
     $d = $this->req->getData();
     $d->loginUsername = $username;
     $d->loginPassword = $password;
     $d->useCookies = '1';
     $d->url = '';
     $html = $this->req->init()->process();
     // check?
     $q1 = new jQuery('div#main p.success', $html);
     $q2 = new jQuery('div#main div..success', $html);
     if (count($q1) == 0 && $q2 === 0) {
         //file_put_contents('D:\html.html',$html);
         $this->logger->writeln('Fehler beim Login. div#main p.success nicht gefunden.');
         throw new \Psc\Exception('Kein Login möglich! div#main p.success nicht gefunden. Output ist: ' . mb_substr($html, 0, 800) . '...');
     }
     $this->sessionId = NULL;
     // ist nicht mehr in der neuen subcentral
     //Preg::qmatch($html,'/index\.php\?s=(.*)$/');
     $this->logger->writeln('Login erfolgreich');
     /* das ist der redirect, den die Seite auch machen würde */
     //$this->req = new URLRequest('http://www.subcentral.de/'.$link);
     //$html = $this->req->init()->process();
     return $html;
 }
Ejemplo n.º 2
0
 protected function assertCommonRequest(Request $request)
 {
     $json = $this->test->json($request->getData());
     $this->assertNotEmpty($json->apikey);
     return $json;
 }