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


PHP HTTP_Request::addCookie方法代码示例

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


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

示例1: array

 /**
  * Create an HTTP_Request object and set all parameters necessary to
  * perform fetches for this comic.
  *
  * @param timestamp $date  Date of the comic to retrieve (default today)
  */
 function _initHTTP($date, $url)
 {
     if (is_null($this->http)) {
         $options = array();
         if (isset($GLOBALS['conf']['http']['proxy']) && !empty($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
             $options = array_merge($options, $GLOBALS['conf']['http']['proxy']);
         }
         require_once 'HTTP/Request.php';
         $this->http = new HTTP_Request($url, $options);
         $v = $this->getOverride("referer", $date);
         if (!is_null($v)) {
             $this->http->addHeader('Referer', $v);
         }
         $v = $this->getOverride("agent");
         if (!is_null($v)) {
             $this->http->addHeader('User-Agent', $v);
         }
         $user = $this->getOverride("user", $date);
         $pass = $this->getOverride("pass", $date);
         if (!is_null($user) and !is_null($pass)) {
             $this->http->setBasicAuth($user, $pass);
         }
         foreach ($this->getOverride('cookies', $date) as $name => $value) {
             $this->http->addCookie($name, $value);
         }
         foreach ($this->getOverride('headers', $date) as $name => $value) {
             $this->addHeader($name, $value);
         }
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:36,代码来源:Comic.php

示例2: request

 /**
  * 配信サーバへリクエストを送信する.
  *
  * @param string $mode
  * @param array $arrParams 追加パラメータ.連想配列で渡す.
  * @return string|object レスポンスボディ|エラー時にはPEAR::Errorオブジェクトを返す.
  */
 function request($mode, $arrParams = array(), $arrCookies = array())
 {
     $objReq = new HTTP_Request();
     $objReq->setUrl(OSTORE_URL . 'upgrade/index.php');
     $objReq->setMethod('POST');
     $objReq->addPostData('mode', $mode);
     $objReq->addPostDataArray($arrParams);
     foreach ($arrCookies as $cookie) {
         $objReq->addCookie($cookie['name'], $cookie['value']);
     }
     $e = $objReq->sendRequest();
     if (PEAR::isError($e)) {
         return $e;
     } else {
         return $objReq;
     }
 }
开发者ID:khrisna,项目名称:eccubedrm,代码行数:24,代码来源:LC_Page_Upgrade_Base.php

示例3: SetTimezone

 private function SetTimezone()
 {
     $request = new HTTP_Request(OX_URL . "/config/timezone", array("method" => "GET"));
     foreach ($this->cookies as $cookie) {
         $request->addCookie($cookie["name"], $cookie["value"]);
     }
     $request->addQueryString("session", $this->session);
     try {
         $request->sendRequest();
         if ($request->getResponseCode() == 200) {
             $reply = $this->json->decode($request->getResponseBody());
             $timezone = $reply["data"];
             date_default_timezone_set($timezone);
             $this->timezone = $timezone;
             $this->offset = date("Z");
             //date_default_timezone_set("UTC");
         } else {
             return false;
         }
     } catch (HTTP_Exception $e) {
         echo $e->getMessage();
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:z-push-svn,代码行数:24,代码来源:ox.php

示例4: getServerResponse

 /**
  * Execute external or internal URLs and return server response.
  *
  * @param string $url
  *   Request URL.
  * @param bool $addCookie
  *   Whether to provide a cookie. Should be true to access internal URLs.
  *
  * @return string
  *   Response from URL.
  */
 public static function getServerResponse($url, $addCookie = TRUE)
 {
     CRM_Core_TemporaryErrorScope::ignoreException();
     require_once 'HTTP/Request.php';
     $request = new HTTP_Request($url);
     if ($addCookie) {
         foreach ($_COOKIE as $name => $value) {
             $request->addCookie($name, $value);
         }
     }
     if (isset($_SERVER['AUTH_TYPE'])) {
         $request->setBasicAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
     }
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'WordPress') {
         session_write_close();
     }
     $request->sendRequest();
     $response = $request->getResponseBody();
     return $response;
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:32,代码来源:System.php

示例5: array

 function _request($url, $body = null, $content_type = 'text/html', $method = 'GET', $headers = array(), $cookies = array())
 {
     set_include_path(_XE_PATH_ . "libs/PEAR");
     require_once 'PEAR.php';
     require_once 'HTTP/Request.php';
     $url_info = parse_url($url);
     $host = $url_info['host'];
     if (__PROXY_SERVER__ !== null) {
         $oRequest = new HTTP_Request(__PROXY_SERVER__);
         $oRequest->setMethod('POST');
         $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers)));
     } else {
         $oRequest = new HTTP_Request($url);
         if (count($headers)) {
             foreach ($headers as $key => $val) {
                 $oRequest->addHeader($key, $val);
             }
         }
         if ($cookies[$host]) {
             foreach ($cookies[$host] as $key => $val) {
                 $oRequest->addCookie($key, $val);
             }
         }
         if (!$content_type) {
             $oRequest->addHeader('Content-Type', 'text/html');
         } else {
             $oRequest->addHeader('Content-Type', $content_type);
         }
         $oRequest->setMethod($method);
         if ($body) {
             $oRequest->setBody($body);
         }
     }
     $oResponse = $oRequest->sendRequest();
     $code = $oRequest->getResponseCode();
     $header = $oRequest->getResponseHeader();
     $response = $oRequest->getResponseBody();
     if ($c = $oRequest->getResponseCookies()) {
         foreach ($c as $k => $v) {
             $cookies[$host][$v['name']] = $v['value'];
         }
     }
     if ($code > 300 && $code < 399 && $header['location']) {
         return $this->_request($header['location'], $body, $content_type, $method, $headers, $cookies);
     }
     if ($code != 200) {
         return;
     }
     return $response;
 }
开发者ID:google-code-backups,项目名称:xe-textyle,代码行数:50,代码来源:blogger.class.php

示例6: s_users_by_uids

function s_users_by_uids(&$uids, $encoded = false)
{
    if (!s_bad_array($uids) || !($uids = array_unique($uids)) || !($uids = array_values($uids)) || empty($uids)) {
        return false;
    }
    //看cache中是否存在
    asort($uids);
    $mem = mem_cache_share();
    $key = md5(MEM_CACHE_KEY_PREFIX . "_user_by_uids_" . implode(",", $uids) . strval($encoded));
    if ($data = $mem->get($key)) {
        //缓存中已经存在
        $data = json_decode($data, true);
    }
    if (!$data) {
        //缓存中没有,请求服务器
        $max = 20;
        $time = 0;
        $times = ceil(count($uids) / $max);
        $list = array();
        do {
            $ids = array();
            $num0 = $time * $max;
            $num1 = ($time + 1) * $max - 1;
            foreach (range($num0, $num1) as $index) {
                if (!isset($uids[$index]) || intval($uids[$index]) <= 0) {
                    break;
                }
                $ids[] = $uids[$index];
            }
            $params = array("uids" => implode(",", $ids), "source" => APP_KEY, "cookie" => array("SUE" => $_COOKIE["SUE"], "SUP" => $_COOKIE["SUP"]));
            $data = s_http_get();
            $req = new HTTP_Request('http://i2.api.weibo.com/2/users/show_batch.json');
            $req->setMethod(HTTP_REQUEST_METHOD_GET);
            $req->addCookie("SUE", URLEncode($_COOKIE["SUE"]));
            $req->addCookie("SUP", URLEncode($_COOKIE["SUP"]));
            $req->addQueryString('uids', implode(",", $ids));
            $req->addQueryString('is_encoded', $encoded === false ? 0 : 1);
            $req->addQueryString('source', MBLOG_APP_KEY);
            $rs = $req->sendRequest();
            if (PEAR::isError($rs) || !($ret = json_decode($req->getResponseBody(), true)) || isset($ret["error_code"])) {
                return false;
            }
            //有可能是空数组
            if (isset($ret["users"])) {
                $list = array_merge($list, $ret["users"]);
            }
            unset($ret);
        } while (++$time < $times);
        $data = array();
        //重新组合成uid => array()
        foreach ($list as &$item) {
            if (isset($item["id"]) && $item["idstr"] > 0) {
                $data[$item["idstr"]] = $item;
            }
            unset($item);
        }
        //检查自己是否在数组中
        if (false !== ($me = login_user_info()) && ($meid = $me["uniqueid"]) && in_array($meid, $uids) && ($me = get_user_by_token(intval($meid)))) {
            $data[$me["id"]] = $me;
        }
        unset($list);
        //缓存十小时
        $mem->set($key, json_encode($data), 0, MEM_CACHE_LIFETIME_LUCKY);
    }
    return $data;
}
开发者ID:anjestar,项目名称:SHFramework,代码行数:66,代码来源:devinc.user.php

示例7: getRemoteResource

 function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array())
 {
     requirePear();
     require_once 'HTTP/Request.php';
     $parsed_url = parse_url(__PROXY_SERVER__);
     if ($parsed_url["host"]) {
         $oRequest = new HTTP_Request(__PROXY_SERVER__);
         $oRequest->setMethod('POST');
         $oRequest->_timeout = $timeout;
         $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data)));
     } else {
         $oRequest = new HTTP_Request($url);
         if (count($headers)) {
             foreach ($headers as $key => $val) {
                 $oRequest->addHeader($key, $val);
             }
         }
         if ($cookies[$host]) {
             foreach ($cookies[$host] as $key => $val) {
                 $oRequest->addCookie($key, $val);
             }
         }
         if (count($post_data)) {
             foreach ($post_data as $key => $val) {
                 $oRequest->addPostData($key, $val);
             }
         }
         if (!$content_type) {
             $oRequest->addHeader('Content-Type', 'text/html');
         } else {
             $oRequest->addHeader('Content-Type', $content_type);
         }
         $oRequest->setMethod($method);
         if ($body) {
             $oRequest->setBody($body);
         }
         $oRequest->_timeout = $timeout;
     }
     $oResponse = $oRequest->sendRequest();
     $code = $oRequest->getResponseCode();
     $header = $oRequest->getResponseHeader();
     $response = $oRequest->getResponseBody();
     if ($c = $oRequest->getResponseCookies()) {
         foreach ($c as $k => $v) {
             $cookies[$host][$v['name']] = $v['value'];
         }
     }
     if ($code > 300 && $code < 399 && $header['location']) {
         return FileHandler::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
     }
     return $response;
 }
开发者ID:leehankyeol,项目名称:module-server,代码行数:52,代码来源:me2day.php

示例8: checkURL

 static function checkURL($url, $addCookie = false)
 {
     CRM_Core_Error::ignoreException();
     require_once 'HTTP/Request.php';
     $params = array('method' => 'GET');
     $request = new HTTP_Request($url, $params);
     if ($addCookie) {
         foreach ($_COOKIE as $name => $value) {
             $request->addCookie($name, $value);
         }
     }
     $config =& CRM_Core_Config::singleton();
     if ($config->userFramework == 'Standalone') {
         session_write_close();
     }
     $request->sendRequest();
     $result = $request->getResponseCode() == 200 ? true : false;
     if ($config->userFramework == 'Standalone') {
         session_start();
     }
     CRM_Core_Error::setCallback();
     return $result;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:23,代码来源:System.php

示例9: resend_request

/**
* Re-send a request after successful re-authentication
*
* Re-creates a GET or POST request based on data passed along in a form. Used
* in case of an expired security token so that the user doesn't lose changes.
*
*/
function resend_request()
{
    global $_CONF;
    require_once 'HTTP/Request.php';
    $method = '';
    if (isset($_POST['token_requestmethod'])) {
        $method = COM_applyFilter($_POST['token_requestmethod']);
    }
    $returnurl = '';
    if (isset($_POST['token_returnurl'])) {
        $returnurl = urldecode($_POST['token_returnurl']);
        if (substr($returnurl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
            // only accept URLs on our site
            $returnurl = '';
        }
    }
    $postdata = '';
    if (isset($_POST['token_postdata'])) {
        $postdata = urldecode($_POST['token_postdata']);
    }
    $getdata = '';
    if (isset($_POST['token_getdata'])) {
        $getdata = urldecode($_POST['token_getdata']);
    }
    $files = '';
    if (isset($_POST['token_files'])) {
        $files = urldecode($_POST['token_files']);
    }
    if (SECINT_checkToken() && !empty($method) && !empty($returnurl) && ($method == 'POST' && !empty($postdata) || $method == 'GET' && !empty($getdata))) {
        $magic = get_magic_quotes_gpc();
        $req = new HTTP_Request($returnurl);
        if ($method == 'POST') {
            $req->setMethod(HTTP_REQUEST_METHOD_POST);
            $data = unserialize($postdata);
            foreach ($data as $key => $value) {
                if ($key == CSRF_TOKEN) {
                    $req->addPostData($key, SEC_createToken());
                } else {
                    if ($magic) {
                        $value = stripslashes_gpc_recursive($value);
                    }
                    $req->addPostData($key, $value);
                }
            }
            if (!empty($files)) {
                $files = unserialize($files);
            }
            if (!empty($files)) {
                foreach ($files as $key => $value) {
                    $req->addPostData('_files_' . $key, $value);
                }
            }
        } else {
            $req->setMethod(HTTP_REQUEST_METHOD_GET);
            $data = unserialize($getdata);
            foreach ($data as $key => $value) {
                if ($key == CSRF_TOKEN) {
                    $req->addQueryString($key, SEC_createToken());
                } else {
                    if ($magic) {
                        $value = stripslashes_gpc_recursive($value);
                    }
                    $req->addQueryString($key, $value);
                }
            }
        }
        $req->addHeader('User-Agent', 'Geeklog/' . VERSION);
        // need to fake the referrer so the new token matches
        $req->addHeader('Referer', COM_getCurrentUrl());
        foreach ($_COOKIE as $cookie => $value) {
            $req->addCookie($cookie, $value);
        }
        $response = $req->sendRequest();
        if (PEAR::isError($response)) {
            if (!empty($files)) {
                SECINT_cleanupFiles($files);
            }
            trigger_error("Resending {$method} request failed: " . $response->getMessage());
        } else {
            COM_output($req->getResponseBody());
        }
    } else {
        if (!empty($files)) {
            SECINT_cleanupFiles($files);
        }
        echo COM_refresh($_CONF['site_url'] . '/index.php');
    }
    // don't return
    exit;
}
开发者ID:milk54,项目名称:geeklog-japan,代码行数:97,代码来源:users.php


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