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


PHP HTTP_Request::addQueryString方法代码示例

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


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

示例1: fetchData

 function fetchData($username, $password)
 {
     switch ($this->options['cryptType']) {
         case 'blowfish':
             include_once 'Crypt/Blowfish.php';
             $bf = new Crypt_Blowfish($this->options['cryptKey']);
             $password = $bf->encrypt($password);
             $password = base64_encode($password);
             break;
         default:
             if (function_exists($this->options['cryptType'])) {
                 $password = $this->options['cryptType']($password);
             }
             break;
     }
     $req = new HTTP_Request();
     $req->setURL($this->options['URL']);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     $req->addQueryString($this->options['usernameKey'], $username);
     $req->addQueryString($this->options['passwordKey'], $password);
     if (!PEAR::isError($req->sendRequest())) {
         $response = $req->getResponseBody();
     } else {
         return false;
     }
     $unserializer = new XML_Unserializer();
     if ($unserializer->unserialize($response)) {
         $this->result_value = $unserializer->getUnserializedData();
         if ($this->result_value[$this->options['resultKey']] == $this->options['correctValue']) {
             return true;
         }
     }
     return false;
 }
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:34,代码来源:REST_XML.php

示例2: checkAddress

 /**
  * @param $values
  *
  * @return bool
  */
 public static function checkAddress(&$values)
 {
     if (self::$_disabled) {
         return FALSE;
     }
     if (!isset($values['street_address']) || !isset($values['city']) && !isset($values['state_province']) && !isset($values['postal_code'])) {
         return FALSE;
     }
     $userID = Civi::settings()->get('address_standardization_userid');
     $url = Civi::settings()->get('address_standardization_url');
     if (empty($userID) || empty($url)) {
         return FALSE;
     }
     $address2 = str_replace(',', '', $values['street_address']);
     $XMLQuery = '<AddressValidateRequest USERID="' . $userID . '"><Address ID="0"><Address1>' . CRM_Utils_Array::value('supplemental_address_1', $values, '') . '</Address1><Address2>' . $address2 . '</Address2><City>' . $values['city'] . '</City><State>' . $values['state_province'] . '</State><Zip5>' . $values['postal_code'] . '</Zip5><Zip4>' . CRM_Utils_Array::value('postal_code_suffix', $values, '') . '</Zip4></Address></AddressValidateRequest>';
     require_once 'HTTP/Request.php';
     $request = new HTTP_Request();
     $request->setURL($url);
     $request->addQueryString('API', 'Verify');
     $request->addQueryString('XML', $XMLQuery);
     $response = $request->sendRequest();
     $session = CRM_Core_Session::singleton();
     $code = $request->getResponseCode();
     if ($code != 200) {
         $session->setStatus(ts('USPS Address Lookup Failed with HTTP status code: %1', array(1 => $code)));
         return FALSE;
     }
     $responseBody = $request->getResponseBody();
     $xml = simplexml_load_string($responseBody);
     if (is_null($xml) || is_null($xml->Address)) {
         $session->setStatus(ts('Your USPS API Lookup has Failed.'));
         return FALSE;
     }
     if ($xml->Number == '80040b1a') {
         $session->setStatus(ts('Your USPS API Authorization has Failed.'));
         return FALSE;
     }
     if (array_key_exists('Error', $xml->Address)) {
         $session->setStatus(ts('Address not found in USPS database.'));
         return FALSE;
     }
     $values['street_address'] = (string) $xml->Address->Address2;
     $values['city'] = (string) $xml->Address->City;
     $values['state_province'] = (string) $xml->Address->State;
     $values['postal_code'] = (string) $xml->Address->Zip5;
     $values['postal_code_suffix'] = (string) $xml->Address->Zip4;
     if (array_key_exists('Address1', $xml->Address)) {
         $values['supplemental_address_1'] = (string) $xml->Address->Address1;
     }
     return TRUE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:56,代码来源:USPS.php

示例3: process

 function process($table, $data)
 {
     $req = new HTTP_Request($this->api_url);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     foreach ($data as $key => $val) {
         $req->addQueryString($key, $val);
     }
     $req->addQueryString('org', trim($this->org_id));
     $req->addQueryString('table', $table);
     if (!PEAR::isError($req->sendRequest())) {
         $out = $req->getResponseBody();
     } else {
         $out = null;
     }
     return $out;
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:16,代码来源:diaRequest.inc.php

示例4: 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

示例5: getTerms

 /**
  * Extract terms from the Solr index.
  *
  * @param string $field					 Field to extract terms from
  * @param string $start					 Starting term to extract (blank for beginning
  * of list)
  * @param int		$limit					 Maximum number of terms to return (-1 for no
  * limit)
  * @param bool	 $returnSolrError Should we fail outright on syntax error
  * (false) or treat it as an empty result set with an error key set (true)?
  *
  * @return array									Associative array parsed from Solr JSON
  * response; meat of the response is in the ['terms'] element, which contains
  * an index named for the requested term, which in turn contains an associative
  * array of term => count in index.
  * @access public
  */
 public function getTerms($field, $start, $limit, $returnSolrError = false)
 {
     $this->client->setMethod('GET');
     $this->client->setURL($this->host . '/term');
     $this->client->addQueryString('terms', 'true');
     $this->client->addQueryString('terms.fl', $field);
     $this->client->addQueryString('terms.lower.incl', 'false');
     $this->client->addQueryString('terms.lower', $start);
     $this->client->addQueryString('terms.limit', $limit);
     $this->client->addQueryString('terms.sort', 'index');
     $this->client->addQueryString('wt', 'json');
     $result = $this->client->sendRequest();
     if (!PEAR_Singleton::isError($result)) {
         // Process the JSON response:
         $data = $this->_process($this->client->getResponseBody(), $returnSolrError);
         // Tidy the data into a more usable format:
         if (isset($data['terms'])) {
             $data['terms'] = array($data['terms'][0] => $this->_processTerms($data['terms'][1]));
         }
         return $data;
     } else {
         return $result;
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:41,代码来源:Solr.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: latlon_placeinfo

function latlon_placeinfo($lat, $lon, $zoom)
{
    $req = new HTTP_Request('http://api.flickr.com/services/rest/');
    $req->addQueryString('method', 'flickr.places.findByLatLon');
    $req->addQueryString('lat', $lat);
    $req->addQueryString('lon', $lon);
    $req->addQueryString('accuracy', $zoom);
    $req->addQueryString('format', 'php_serial');
    $req->addQueryString('api_key', FLICKR_KEY);
    $res = $req->sendRequest();
    if (PEAR::isError($res)) {
        return '';
    }
    if ($req->getResponseCode() == 200) {
        $rsp = unserialize($req->getResponseBody());
        if (is_array($rsp['places']) && is_array($rsp['places']['place'])) {
            $places = $rsp['places']['place'];
            if (is_array($places[0]) && $places[0]['name']) {
                list($place_name, $place_woeid) = array($places[0]['name'], $places[0]['woeid']);
                $req = new HTTP_Request('http://api.flickr.com/services/rest/');
                $req->addQueryString('method', 'flickr.places.getInfo');
                $req->addQueryString('woe_id', $place_woeid);
                $req->addQueryString('format', 'php_serial');
                $req->addQueryString('api_key', FLICKR_KEY);
                $res = $req->sendRequest();
                if (PEAR::isError($res)) {
                    return array(null, null, null, null, null, null);
                }
                $rsp = unserialize($req->getResponseBody());
                if (is_array($rsp) && is_array($rsp['place'])) {
                    list($country, $region) = array($rsp['place']['country'], $rsp['place']['region']);
                    if (is_array($country)) {
                        list($country_name, $country_woeid) = array($country['_content'], $country['woeid']);
                    }
                    if (is_array($region)) {
                        list($region_name, $region_woeid) = array($region['_content'], $region['woeid']);
                    }
                }
                return array($country_name, $country_woeid, $region_name, $region_woeid, $place_name, $place_woeid);
            }
        }
    }
    return array(null, null, null, null, null, null);
}
开发者ID:ndpgroup,项目名称:fp-legacy,代码行数:44,代码来源:data.php

示例8: callMethod

 /**
  * callMethod
  *
  * @access private
  * @param string $method_name
  * @param array  $send_param
  * @param string $method
  * @return string result XML data
  */
 private function callMethod($method_name, $send_param = array(), $method = 'post')
 {
     $request = new HTTP_Request($this->api_url . $method_name);
     $request->setBasicAuth($this->username, $this->password);
     if ($method == "post") {
         $request->setMethod(HTTP_REQUEST_METHOD_POST);
     }
     if (count($send_param) != 0) {
         foreach ($send_param as $key => $value) {
             if ($key == "photo" && $method_name == "photo_add") {
                 $request->addFile($key, $value, $this->getMime($value));
             } else {
                 if ($method == "post") {
                     $request->addPostData($key, $value, true);
                 } else {
                     $request->addQueryString($key, $value, true);
                 }
             }
         }
     }
     $response = $request->sendRequest();
     if (PEAR::isError($response)) {
         return $response;
     } else {
         $body = $request->getResponseBody();
         if (strpos($body, 'rsp stat="fail"') !== false) {
             preg_match('|err code="(.*?)" msg="(.*?)"|', $body, $matches);
             $code = 0;
             if (isset($this->error_code[$matches[1]])) {
                 $code = $this->error_code[$matches[1]];
             }
             return PEAR::raiseError($matches[1] . ':' . $matches[2], $code);
         } else {
             return $body;
         }
     }
 }
开发者ID:rsky,项目名称:tweetie2photozou,代码行数:46,代码来源:Photozou.php

示例9: foreach

    $v = false;
    foreach ($_POST as $key => $value) {
        if ($key == "DESKTOP_XSITE_PARAMS" || $key == "dojo_preventCache") {
            continue;
        }
        if (!$v) {
            $v = true;
            $p->setMethod(HTTP_REQUEST_METHOD_POST);
        }
        $p->addPostData($key, $value);
    }
    foreach ($_GET as $key => $value) {
        if ($key == "DESKTOP_XSITE_PARAMS") {
            continue;
        }
        $p->addQueryString($key, $value);
    }
    $p->sendRequest();
    $type = $p->getResponseHeader("Content-Type");
    header("Content-Type: {$type}");
    foreach (array("400" => "Bad syntax", "401" => "Unauthorized", "402" => "Not Used (Payment Granted)", "403" => "Forbidden", "404" => "Not Found", "500" => "Internal Error", "501" => "Not Implemented", "502" => "Overloaded", "503" => "Gateway Timeout") as $key => $value) {
        if ($p->getResponseCode() == $key) {
            header("HTTP/1.0 " . $key . " " . $value);
        }
    }
    $body = $p->getResponseBody();
    echo $body;
    $p->disconnect();
} else {
    internal_error("permission_denied");
}
开发者ID:Rudi9719,项目名称:lucid,代码行数:31,代码来源:xsite.php

示例10:

 function geocoder_getdata()
 {
     $req = new HTTP_Request("http://rpc.geocoder.us/service/rest");
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     // assumes $address is *not* urlencoded
     $geoaddress = $this->Street . ", " . $this->City . ", " . $this->State . ", " . $this->Zip;
     $req->addQueryString('address', $geoaddress);
     $req->addHeader("User-Agent", "RadicalDesigns/AMP");
     if (!PEAR::isError($req->sendRequest())) {
         $result = $req->getResponseBody();
     } else {
         // failed
         $result = $req->getResponseHeader();
         //print "there was an error...";
     }
     // echo '<pre><br>geocode result<br>';var_dump($result);echo '</pre><br>';
     $xmlparser = new XML_Unserializer();
     $parse_result = $xmlparser->unserialize($result, false);
     /*
       if ( PEAR::isError( $parse_result )) {
     	print 'yah<BR>';
     } else {
     	print 'nah<BR>';
     }
     */
     $data = $xmlparser->getUnserializedData();
     if (array_key_exists('geo:lat', $data['geo:Point'])) {
         //return array( $data['geo:Point']['geo:lat'], $data['geo:Point']['geo:long'],$result );
         $this->lat = $data['geo:Point']['geo:lat'];
         $this->long = $data['geo:Point']['geo:long'];
     } else {
         #print_r (($data));
         //return array( $data['geo:Point'][0]['geo:lat'], $data['geo:Point'][0]['geo:long'],$result );
     }
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:35,代码来源:Geo.php

示例11: 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

示例12: request

	/**
	 * Generates an API request
	 * 
	 * @param $path string The path, eg "slices"
	 * @param $id string The id of the object, optional and really only used for slices and zones
	 * @param $action string Any action to take on the object, for instance "reboot"
	 * @param $method string The HTTP method for the request
	 * @param $parameters array Any post/query string parameters
	 * @param $postbody string The raw postbody, used in lieu of $parameters
	 * @return string The response body
	 */
	public function request($path,$id=null,$action=null,$method='GET',$parameters=null,$postbody=null,$cached=false)
	{
		// append slashes where needed
		if ($id!='')
			$path.='/';
		if (($action!=null) && ($id!=null))
			$id.='/';
			
		// build the url
		$url="https://api.slicehost.com/{$path}{$id}{$action}.xml";
		
		if ($cached)
		{
			if (isset(self::$_cache[$url]))
			{
				return self::$_cache[$url];
			}
		}

		// create a request
		$request=new HTTP_Request($url);

		// set the auth
		$request->setBasicAuth($this->key,'');
		
		// set the method
		$method=strtoupper($method);
		$request->setMethod($method);
		
		// $postbody was specified, so this is an xml request
		if ($postbody)
		{
			$request->addHeader('Content-Type','text/xml');
			$request->addRawPostData($postbody);
		}
			
		// since we are posting well formed xml documents instead of
		// post data, all the parameters will be appended as query strings
		// since they are only used in the api in weird places.
		if ($parameters)
			foreach($parameters as $key=>$value)
				$request->addQueryString($key,$value);
				
		// send it off
		$request->sendRequest(true);
		
		// if success, build the response objects, otherwise throw an exception.
		$repcode=$request->getResponseCode();
		switch($repcode)
		{
			case 200:
			case 201:
			case 204:
				$result=$this->build_response($request->getResponseBody());
				self::$_cache[$url]=$result;
				return $result;
			default:
				throw new SlicehostException("$url.\nResponse Code $repcode.\n\n{$request->getResponseBody()}\n\n");
		}
		
		
	}
开发者ID:jawngee,项目名称:Thor,代码行数:73,代码来源:slicehost.php

示例13: flickr_place_info

function flickr_place_info(&$C, $woe_id)
{
    $req = new HTTP_Request('http://api.flickr.com/services/rest/?format=json&nojsoncallback=1&method=flickr.places.getInfo');
    $req->addQueryString('api_key', $C->flickr_key);
    $req->addQueryString('woe_id', $woe_id);
    $res = $req->sendRequest();
    if (PEAR::isError($res)) {
        die_with_code(500, "{$res->message}\n");
    }
    if ($req->getResponseCode() == 200) {
        if ($response = json_decode($req->getResponseBody())) {
            if ($response->stat == 'ok') {
                return $response->place;
            }
        }
    }
    // one place
    return false;
}
开发者ID:RandomEtc,项目名称:apimaps,代码行数:19,代码来源:data.php

示例14: send

	/**
	 * Sends the request
	 *
	 * @return SimpleXMLElement
	 */
	public function send($queue=null)
	{
		$this->parameters['Signature']=$this->sign('GET',$queue);

 		$request=new HTTP_Request($this->endpoint);
		$request->setMethod('GET');
		foreach($this->parameters as $name=>$value)
			$request->addQueryString($name,$value);
			
		$misses=0;
		for(;;)
		{
			$request->sendRequest();
		
			//@TODO: Add handling for different status codes
			if ($request->getResponseCode()==200)
				break;
				
			$misses++;
			sleep($misses);
			
			if ($misses==3)
				throw new AWSException($request->getResponseBody());
		}

		$body=$request->getResponseBody();
		$response=simplexml_load_string($body);

		if ($response->Errors)
			throw new AWSException($response->Errors->Error->Message);
			
		return $response;
	}
开发者ID:nikels,项目名称:HeavyMetal,代码行数:38,代码来源:aws_request.php


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