コード例 #1
0
ファイル: class.Facebook.php プロジェクト: rchicoria/epp-drs
		/**
		 * Login to account
		 * 
		 * @var string email
		 * @var string password
		 */
		function Login($email, $password)
		{
			$this->Username = $email;
			$this->Password = $password;
			$this->LoggedIn = false;
			
			if (!class_exists('FacebookAPI'))
				return;
			
			$this->Client = new FacebookAPI(self::REST_SERVER_ADDR, $this->API_Key, $this->Secret);

			$params = array(
				'email' => trim($this->Username),
				'pass' => trim($this->Password),
				'md5pass' => '',
				'challenge' => md5(time()),
				'noerror' => 1,
				'api_key' => $this->API_Key,
				'next' => '',
				'v' => '1.0'
			);
			
			
			$this->UseRedirects();
			$this->UseCookies();
			$this->ReceiveHeaders();
			$this->Fetch(self::LOGIN_URL, $params, true);

			preg_match("/auth\_token=([a-z0-9]+)/msi", $this->Result, $auth);
			$this->AuthToken = $auth[1];

			if (!$this->AuthToken)
			{
				$form = HTMLParser::GetFormDetails($this->Result, null, 'grant_perm');
				if (!$form) return;
				if ($form['elements']['cancel']) unset($form['elements']['cancel']);

				
				$this->Fetch($form['action'], $form['elements'], true);
				
				if (!$this->Result)
					return false;
	
				preg_match("/auth\_token=([a-z0-9]+)/msi", $this->Result, $auth);
				$this->AuthToken = $auth[1];
			}

			if ($this->AuthToken)
			{
				$this->LoggedIn = true;
				$this->SessionInfo = $this->Client->GetSession($this->AuthToken);
				return true;
			}
		}