当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Http_Client::setCookie方法代码示例

本文整理汇总了PHP中Zend_Http_Client::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client::setCookie方法的具体用法?PHP Zend_Http_Client::setCookie怎么用?PHP Zend_Http_Client::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Http_Client的用法示例。


在下文中一共展示了Zend_Http_Client::setCookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logoutAction

 public function logoutAction()
 {
     $serverUrl = 'http://' . AUTH_SERVER . self::AUTH_PATH . '/logout';
     $client = new Zend_Http_Client($serverUrl, array('timeout' => 30));
     try {
         if (isset($_COOKIE[self::AUTH_SID])) {
             $moduleName = $this->getRequest()->getModuleName();
             $client->setCookie('PHPSESSID', $_COOKIE[self::AUTH_SID]);
             $client->setCookie('moduleName', $moduleName);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = $response->getStatus() . ' : ' . $response->getMessage() . '<br/>' . $response->getBody();
                 throw new Zend_Exception($remoteErr, Zend_Log::ERR);
             }
         } else {
             $this->_helper->logger('No remote cookie found');
         }
     } catch (Zend_Exception $e) {
         echo $e->getMessage();
     }
     if (isset($_COOKIE[self::AUTH_SID])) {
         preg_match('/[^.]+\\.[^.]+$/', $_SERVER['SERVER_NAME'], $domain);
         setcookie(self::AUTH_SID, '', time() - 360000, self::AUTH_PATH, ".{$domain['0']}");
     }
     Zend_Auth::getInstance()->clearIdentity();
     Zend_Session::destroy();
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:27,代码来源:AuthenticateController.php

示例2: logoutAction

 public function logoutAction()
 {
     $this->_helper->layout()->disableLayout();
     $serverUrl = 'http://' . AUTH_SERVER . self::AUTH_PATH . '/logout';
     $client = new Zend_Http_Client($serverUrl, array('timeout' => 30));
     try {
         if (isset($_COOKIE[self::AUTH_SID])) {
             $moduleName = $this->getRequest()->getModuleName();
             $client->setCookie('PHPSESSID', $_COOKIE[self::AUTH_SID]);
             $client->setCookie('moduleName', $moduleName);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage() . ', i.e. ' . $response->getHeader('Message');
                 throw new Zend_Exception($remoteErr, Zend_Log::ERR);
             }
         } else {
             $this->_helper->logger('No remote cookie found. So, not requesting AUTH_SERVER to logout.');
         }
     } catch (Zend_Exception $e) {
         echo $e->getMessage();
     }
     preg_match('/[^.]+\\.[^.]+$/', $_SERVER['SERVER_NAME'], $domain);
     if (isset($_COOKIE[self::AUTH_SID])) {
         setcookie(self::AUTH_SID, '', time() - 360000, self::AUTH_PATH, ".{$domain['0']}");
     }
     if (isset($_COOKIE['last'])) {
         setcookie('last', '', time() - 36000, '/', ".{$domain['0']}");
     }
     if (isset($_COOKIE['identity'])) {
         setcookie('identity', '', time() - 36000, '/', ".{$domain['0']}");
     }
     Zend_Auth::getInstance()->clearIdentity();
     Zend_Session::destroy();
     Zend_Session::regenerateId();
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:35,代码来源:AuthenticateController.php

示例3: studentAction

 /**
  * The default action - show the home page
  */
 public function studentAction()
 {
     $this->_helper->viewRenderer->setNoRender(false);
     $request = $this->getRequest();
     $department = $request->getParam('department_id');
     $degree = $request->getParam('degree_id');
     $batch = $request->getParam('batch');
     if (isset($degree) and isset($department) and isset($batch)) {
         $client = new Zend_Http_Client('http://' . CORE_SERVER . '/batch/getbatchstudent' . "?department_id={$department}" . "&degree_id={$degree}" . "&batch_id={$batch}");
         $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
         $response = $client->request();
         if ($response->isError()) {
             $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getHeader('Message');
             throw new Zend_Exception($remoteErr, Zend_Log::ERR);
         } else {
             $jsonContent = $response->getBody($response);
             $students = Zend_Json::decode($jsonContent);
             $this->_helper->logger($jsonContent);
             $this->view->assign('students', $students);
             $this->view->assign('department', $department);
             $this->view->assign('degree', $degree);
             $this->view->assign('batch', $batch);
         }
     }
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:28,代码来源:BarcodeController.php

示例4: login

 public static function login($request)
 {
     $blogPath = SJB_Settings::getSettingByName('blog_path');
     if (empty($blogPath)) {
         return;
     }
     $username = $request['username'];
     $password = $request['password'];
     $userInfo = SJB_UserManager::getUserInfoByUserName($username);
     $userInfo = $userInfo ? base64_encode(serialize($userInfo)) : false;
     $url = SJB_System::getSystemSettings('SITE_URL') . $blogPath . '/wp-login.php';
     $client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent(), 'maxredirects' => 0));
     $client->setCookieJar();
     $client->setCookie($_COOKIE);
     $client->setMethod(Zend_Http_Client::POST);
     $client->setParameterPost(array('log' => $username, 'pwd' => $password, 'noSJB' => 1, 'userInfo' => $userInfo, 'wp-submit' => 'Log in'));
     try {
         $response = $client->request();
         foreach ($response->getHeaders() as $key => $header) {
             if ('set-cookie' == strtolower($key)) {
                 if (is_array($header)) {
                     foreach ($header as $val) {
                         header("Set-Cookie: " . $val, false);
                     }
                 } else {
                     header("Set-Cookie: " . $header, false);
                 }
             }
         }
         $_SESSION['wp_cookie_jar'] = @serialize($client->getCookieJar());
     } catch (Exception $ex) {
     }
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:33,代码来源:wordpress_bridge_plugin.php

示例5: logout

 static function logout()
 {
     SessionStorage::destroy(SJB_Session::getSessionId());
     $forumPath = SJB_Settings::getSettingByName('forum_path');
     if (empty($forumPath)) {
         return;
     }
     $url = SJB_System::getSystemSettings('SITE_URL') . $forumPath . '/';
     $client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent()));
     $client->setCookie($_COOKIE);
     $client->setCookieJar();
     try {
         $response = $client->request();
         $matches = array();
         if (preg_match('/\\.\\/ucp.php\\?mode=logout\\&amp;sid=([\\w\\d]+)"/', $response->getBody(), $matches)) {
             $sid = $matches[1];
             $client->setUri($url . 'ucp.php?mode=logout&sid=' . $sid);
             $response = $client->request();
             foreach ($response->getHeaders() as $key => $header) {
                 if ('set-cookie' == strtolower($key)) {
                     if (is_array($header)) {
                         foreach ($header as $val) {
                             header("Set-Cookie: " . $val, false);
                         }
                     } else {
                         header("Set-Cookie: " . $header, false);
                     }
                 }
             }
         }
     } catch (Exception $ex) {
     }
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:33,代码来源:phpbb_bridge_plugin.php

示例6: post

 /**
  * POST xml data to Google with authorization headers set
  *
  * @param string $xml
  * @param string $uri POST URI
  * @return Zend_Http_Response
  */
 public function post($xml, $uri = null)
 {
     if ($uri == null) {
         $uri = $this->_defaultPostUri;
     }
     if ($uri == null) {
         throw Zend::exception('Zend_Gdata_Exception', 'You must specify an URI to which to post.');
     }
     $this->_httpClient->setUri($uri);
     $this->_httpClient->setConfig(array('maxredirects' => 0));
     $this->_httpClient->setRawData($xml, 'application/atom+xml');
     $response = $this->_httpClient->request('POST');
     //set "S" cookie to avoid future redirects.
     if ($cookie = $response->getHeader('Set-cookie')) {
         list($cookieName, $cookieValue) = explode('=', $cookie, 2);
         $this->_httpClient->setCookie($cookieName, $cookieValue);
     }
     if ($response->isRedirect()) {
         //this usually happens. Re-POST with redirected URI.
         $this->_httpClient->setUri($response->getHeader('Location'));
         $this->_httpClient->setRawData($xml, 'application/atom+xml');
         $response = $this->_httpClient->request('POST');
     }
     if (!$response->isSuccessful()) {
         throw Zend::exception('Zend_Gdata_Exception', 'Post to Google failed.');
     }
     return $response;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:35,代码来源:Gdata.php

示例7: _fetchPersonalInfo

 public function _fetchPersonalInfo()
 {
     $faculty_id = $this->getFacultyId();
     $cache = self::getCache('remote');
     $facultyPersonal = $cache->load('facultyPersonal');
     // see if a cache already exists:
     if ($facultyPersonal === false or !isset($facultyPersonal[$faculty_id])) {
         $PROTOCOL = 'http://';
         $URL_STAFF_INFO = $PROTOCOL . CORE_SERVER . '/staff/getinfo' . "?staff_id={$faculty_id}";
         $client = new Zend_Http_Client($URL_STAFF_INFO);
         $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
         $response = $client->request();
         if ($response->isError()) {
             $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
             Zend_Registry::get('logger')->err($remoteErr);
             throw new Zend_Exception($remoteErr, Zend_Log::ERR);
         } else {
             $jsonContent = $response->getBody();
             $facultyInfo = Zend_Json_Decoder::decode($jsonContent);
             $facultyPersonal[$faculty_id] = $facultyInfo;
             $cache->save($facultyPersonal, 'facultyPersonal');
         }
     }
     return $facultyPersonal[$faculty_id];
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:25,代码来源:Faculty.php

示例8: post

 /**
  * POST data to Google with authorization headers set
  *
  * @param mixed $data The Zend_Gdata_App_Entry or XML to post
  * @param string $uri POST URI
  * @return Zend_Http_Response
  * @throws Zend_Gdata_App_Exception
  * @throws Zend_Gdata_App_HttpException
  * @throws Zend_Gdata_App_InvalidArgumentException
  */
 public function post($data, $uri = null)
 {
     require_once 'Zend/Http/Client/Exception.php';
     if (is_string($data)) {
         $rawData = $data;
     } elseif ($data instanceof Zend_Gdata_App_Entry) {
         $rawData = $data->saveXML();
     } else {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('You must specify the data to post as either a string or a child of Zend_Gdata_App_Entry');
     }
     if ($uri == null) {
         $uri = $this->_defaultPostUri;
     }
     if ($uri == null) {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('You must specify an URI to which to post.');
     }
     $this->_httpClient->setUri($uri);
     $this->_httpClient->setConfig(array('maxredirects' => 0));
     $this->_httpClient->setRawData($rawData, 'application/atom+xml');
     try {
         $response = $this->_httpClient->request('POST');
     } catch (Zend_Http_Client_Exception $e) {
         require_once 'Zend/Gdata/App/HttpException.php';
         throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
     }
     /**
      * set "S" cookie to avoid future redirects.
      */
     if ($cookie = $response->getHeader('Set-cookie')) {
         list($cookieName, $cookieValue) = explode('=', $cookie, 2);
         $this->_httpClient->setCookie($cookieName, $cookieValue);
     }
     if ($response->isRedirect()) {
         /**
          * Re-POST with redirected URI.
          * This happens frequently.
          */
         $this->_httpClient->setUri($response->getHeader('Location'));
         $this->_httpClient->setRawData($rawData, 'application/atom+xml');
         try {
             $response = $this->_httpClient->request('POST');
         } catch (Zend_Http_Client_Exception $e) {
             throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
         }
     }
     if (!$response->isSuccessful()) {
         require_once 'Zend/Gdata/App/HttpException.php';
         $exception = new Zend_Gdata_App_HttpException('Expected response code 200, got ' . $response->getStatus());
         $exception->setResponse($response);
         throw $exception;
     }
     return $response;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:65,代码来源:App.php

示例9: testUnsetCookieJar

 /**
  * Test we can unset a cookie jar
  *
  */
 public function testUnsetCookieJar()
 {
     // Set the cookie jar just like in testSetNewCookieJar
     $this->client->setCookieJar();
     $this->client->setCookie('cookie', 'value');
     $this->client->setCookie('chocolate', 'chips');
     $jar = $this->client->getCookieJar();
     // Try unsetting the cookiejar
     $this->client->setCookieJar(null);
     $this->assertNull($this->client->getCookieJar(), 'Cookie jar is expected to be null but it is not');
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:15,代码来源:StaticTest.php

示例10: getMemberInfo

 public static function getMemberInfo($memberId)
 {
     $PROTOCOL = 'http://';
     $membership = self::getMembership($memberId);
     $memberType = strtoupper($membership['member_type_id']);
     Zend_Registry::get('logger')->debug($membership);
     $memberInfo = $membership;
     switch ($memberType) {
         case 'STUDENT':
             $URL_STU_INFO = $PROTOCOL . CORE_SERVER . '/student/getinfo' . "?rollno={$memberId}";
             $client = new Zend_Http_Client($URL_STU_INFO);
             $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
                 Zend_Registry::get('logger')->err($remoteErr);
                 /**
                  * @todo Surpress Remote Error.
                  */
                 //throw new Zend_Exception ( $remoteErr, Zend_Log::ERR );
                 $memberInfo['info'] = array();
                 return $memberInfo;
             }
             $jsonContent = $response->getBody($response);
             $memberInfo['info'] = Zend_Json_Decoder::decode($jsonContent);
             return $memberInfo;
         case 'STAFF':
             $URL_STAFF_INFO = $PROTOCOL . CORE_SERVER . '/staff/getinfo' . "?staff_id={$memberId}";
             $client = new Zend_Http_Client($URL_STAFF_INFO);
             $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
                 Zend_Registry::get('logger')->err($remoteErr);
                 /**
                  * @todo Surpress Remote Error.
                  */
                 //throw new Zend_Exception ( $remoteErr, Zend_Log::ERR );
                 $memberInfo['info'] = array();
                 return $memberInfo;
             }
             $jsonContent = $response->getBody($response);
             $memberInfo['info'] = Zend_Json_Decoder::decode($jsonContent);
             return $memberInfo;
         case 'BOOKBANK':
             $memberInfo['info'] = array('first_name' => strtoupper($memberId));
             return $memberInfo;
         default:
             throw new Zend_Exception('Unknown member type : "' . $memberType . '"', Zend_Log::WARN);
     }
     // TODO Name, Department etc
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:52,代码来源:Member.php

示例11: fetchUrl

 public static function fetchUrl($url)
 {
     $http_client = new Zend_Http_Client();
     $http_client->setConfig(array('maxredirects' => 1, 'timeout' => 30, 'keepalive' => false));
     $http_client->setMethod(Zend_Http_Client::GET);
     $http_client->setUri($url);
     $http_client->setCookie('int-SC2', '1');
     $response = $http_client->request();
     if ($response->isError()) {
         throw new Exception('Http request at "' . $url . '" failed with error code "' . $response->getStatus() . '"');
     }
     return utf8_decode($response->getBody());
 }
开发者ID:istobran,项目名称:sage-replay-parser-php,代码行数:13,代码来源:Starcraft2.php

示例12: banRegexp

 /**
  * Add a ban expression to the varnish ban list 
  * If $perClient is set to true, the BAN will be only for a per-client cached object
  *
  * @param unknown_type $regexp
  * @param unknown_type $perClient
  */
 public function banRegexp($regexp, $perClient = false)
 {
     if (!Mage::getStoreConfig('varnish/varnish/active')) {
         return false;
     }
     $httpAdapter = new Zend_Http_Client(Mage::getBaseUrl());
     $httpAdapter->setHeaders("X-Magento-Regexp", $regexp);
     if ($perClient) {
         $httpAdapter->setCookie('frontend', Mage::app()->getRequest()->getCookie('frontend'));
     }
     $response = $httpAdapter->request("BAN");
     return $response;
 }
开发者ID:mwin007,项目名称:Magento-Varnish,代码行数:20,代码来源:Cache.php

示例13: testSetCookieObjectJar

 /**
  * Make sure we can set cookie objects with a jar
  *
  */
 public function testSetCookieObjectJar()
 {
     $this->client->setUri($this->baseuri . 'testCookies.php');
     $this->client->setCookieJar();
     $refuri = $this->client->getUri();
     $cookies = array(Zend_Http_Cookie::fromString('chocolate=chips', $refuri), Zend_Http_Cookie::fromString('crumble=apple', $refuri));
     $strcookies = array();
     foreach ($cookies as $c) {
         $this->client->setCookie($c);
         $strcookies[$c->getName()] = $c->getValue();
     }
     $res = $this->client->request();
     $this->assertEquals($res->getBody(), serialize($strcookies), 'Response body does not contain the expected cookies');
 }
开发者ID:lortnus,项目名称:zf1,代码行数:18,代码来源:SocketTest.php

示例14: _request

 /**
  * 
  * @param string $url
  * @param array $param
  * @param string $method
  * @return string
  */
 protected function _request($url, $param = array(), $method = Zend_Http_Client::POST)
 {
     if ($this->_client === null) {
         $config = array('useragent' => 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/44.0', 'encodecookies' => false, 'timeout' => 180);
         $this->_client = new Zend_Http_Client($url, $config);
         $this->_client->setCookieJar();
     }
     $this->_client->resetParameters()->setUri($url);
     if (count($param['post']) > 0) {
         foreach ($param['post'] as $name => $value) {
             $this->_client->setParameterPost($name, $value);
         }
     }
     if (count($param['get']) > 0) {
         foreach ($param['get'] as $name => $value) {
             $this->_client->setParameterPost($name, $value);
         }
     }
     if (count($param['file']) > 0) {
         foreach ($param['file'] as $name => $value) {
             $this->_client->setFileUpload($value, $name);
         }
     }
     if (count($param['cookie']) > 0) {
         foreach ($param['cookie'] as $name => $value) {
             $this->_client->setCookie($name, $value);
         }
     }
     if (count($this->_cookies) > 0) {
         foreach ($this->_cookies as $cookie) {
             $this->_client->setCookie($cookie);
         }
     }
     $response = $this->_client->request($method);
     $this->_cookies = $this->_client->getCookieJar()->getAllCookies();
     return $response->getBody();
 }
开发者ID:rtsantos,项目名称:mais,代码行数:44,代码来源:Tokio.php

示例15: login

 /**
  * Faz o login na wiki usando a API
  *
  * @param string $url
  * @param string $user
  * @param string $password
  *
  * @return boolean|string   Retorna TRUE ou o erro encontrado
  */
 static function login($url, $user = null, $password = null)
 {
     // Se não foi fornecido um usuário/senha, irá considerar que a url é o tipo de usuário
     if (is_null($user)) {
         $usuario = self::getUser($url);
         $url = $usuario['apiurl'];
         $user = $usuario['user_name'];
         $password = $usuario['user_password'];
     }
     // Cria o cliente
     $client = new Zend_Http_Client();
     // Faz o login inicial
     $client->setUri($url);
     $client->setHeaders('Accept-Encoding', 'none');
     $client->setParameterPost('action', 'login');
     $client->setParameterPost('lgname', $user);
     $client->setParameterPost('lgpassword', $password);
     $client->setParameterPost('format', 'php');
     $response = $client->request(Zend_Http_Client::POST);
     $result = unserialize($response->getBody());
     //RW_Debug::dump($response);
     //RW_Debug::dump($result);
     $client->setParameterPost('lgtoken', $result['login']['token']);
     $client->setCookie($result['login']['cookieprefix'] . '_session', $result['login']['sessionid']);
     // Recupera o token
     $response = $client->request(Zend_Http_Client::POST);
     $result = unserialize($response->getBody());
     //RW_Debug::dump($response);
     //RW_Debug::dump($result);
     //RW_Debug::dump($client->getLastRequest());
     // Configura o Cookie da Sessão
     if ($result['login']['result'] === 'Success') {
         setcookie($result['login']['cookieprefix'] . 'LoggedOut', '-', 1, '/', $_SERVER['HTTP_HOST'], false, true);
         setcookie($result['login']['cookieprefix'] . '_session', $result['login']['sessionid'], time() + 7200, '/', $_SERVER['HTTP_HOST'], false, true);
         setcookie($result['login']['cookieprefix'] . 'UserName', $result['login']['lgusername'], time() + 7200, '/', $_SERVER['HTTP_HOST'], false, true);
         setcookie($result['login']['cookieprefix'] . 'UserID', $result['login']['lguserid'], time() + 7200, '/', $_SERVER['HTTP_HOST'], false, true);
         setcookie($result['login']['cookieprefix'] . 'Token', $result['login']['lgtoken'], time() + 7200, '/', $_SERVER['HTTP_HOST'], false, true);
         return true;
     } else {
         return $result['login']['result'];
     }
 }
开发者ID:realejo,项目名称:library-zf1,代码行数:51,代码来源:Mediawiki.php


注:本文中的Zend_Http_Client::setCookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。