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


PHP _http_build_query函数代码示例

本文整理汇总了PHP中_http_build_query函数的典型用法代码示例。如果您正苦于以下问题:PHP _http_build_query函数的具体用法?PHP _http_build_query怎么用?PHP _http_build_query使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _http_build_query

function _http_build_query($data, $prefix = null, $sep = null, $key = '', $urlencode = true)
{
    $ret = array();
    foreach ((array) $data as $k => $v) {
        if ($urlencode) {
            $k = urlencode($k);
        }
        if (is_int($k) && $prefix != null) {
            $k = $prefix . $k;
        }
        if (!empty($key)) {
            $k = $key . '%5B' . $k . '%5D';
        }
        if ($v === NULL) {
            continue;
        } elseif ($v === FALSE) {
            $v = '0';
        }
        if (is_array($v) || is_object($v)) {
            array_push($ret, _http_build_query($v, '', $sep, $k, $urlencode));
        } elseif ($urlencode) {
            array_push($ret, $k . '=' . urlencode($v));
        } else {
            array_push($ret, $k . '=' . $v);
        }
    }
    if (NULL === $sep) {
        $sep = ini_get('arg_separator.output');
    }
    return implode($sep, $ret);
}
开发者ID:HaThuy92,项目名称:hathithuy_quanlytinchi,代码行数:31,代码来源:php-capabilities.php

示例2: geocodeAddress

 public function geocodeAddress($address, $sensor = false)
 {
     $result = null;
     // URL
     $url = sprintf(self::API_END_POINT . '%s/%s?%s', 'geocode', self::OUTPUT_JSON, _http_build_query(array('address' => $address, 'sensor' => $sensor ? 'true' : 'false')));
     $response = wp_remote_get($url);
     if (is_wp_error($response)) {
     } else {
         $body = $response['body'];
         $result = json_decode($body);
     }
     return $result;
 }
开发者ID:Warpsmith,项目名称:wp-pronamic-google-maps,代码行数:13,代码来源:ApiClient.php

示例3: bootstrap

 /**
  * Constructs and initliaze an Google Maps admin
  */
 public static function bootstrap()
 {
     global $wp_version;
     // Actions and hooks
     if (version_compare($wp_version, '3.3', '<')) {
         add_action('wp_footer', array(__CLASS__, 'printScripts'));
     }
     // Scripts
     wp_register_style('pronamic_google_maps_fix', plugins_url('css/fix.css', Pronamic_Google_Maps_Maps::$file));
     // Scripts
     wp_register_script('pronamic_google_maps_site', plugins_url('js/site.js', Pronamic_Google_Maps_Maps::$file), array('jquery', 'google-jsapi'));
     // Settings
     $other_params_array = array('sensor' => 'false');
     $other_params_array = apply_filters('pronamic_google_maps_load_other_params_array', $other_params_array);
     $other_params_string = _http_build_query($other_params_array, null, '&');
     $other_params_string = apply_filters('pronamic_google_maps_load_other_params_string', $other_params_string);
     wp_localize_script('pronamic_google_maps_site', 'pronamic_google_maps_settings', array('visualRefresh' => get_option('pronamic_google_maps_visual_refresh'), 'other_params' => $other_params_string));
 }
开发者ID:Warpsmith,项目名称:wp-pronamic-google-maps,代码行数:21,代码来源:Site.php

示例4: request_token

 function request_token()
 {
     Keyring_Util::debug('Keyring_Service_OAuth2::request_token()');
     if (!isset($_REQUEST['nonce']) || !wp_verify_nonce($_REQUEST['nonce'], 'keyring-request-' . $this->get_name())) {
         Keyring::error(__('Invalid/missing request nonce.', 'keyring'));
         exit;
     }
     // Need to create a request token now, so that we have a state to pass
     $request_token = new Keyring_Request_Token($this->get_name(), array(), apply_filters('keyring_request_token_meta', array('for' => isset($_REQUEST['for']) ? (string) $_REQUEST['for'] : false), $this->get_name(), array(), $this));
     $request_token = apply_filters('keyring_request_token', $request_token, $this);
     $request_token_id = $this->store_token($request_token);
     $url = $this->authorize_url;
     if (!stristr($url, '?')) {
         $url .= '?';
     }
     $params = array('response_type' => 'code', 'client_id' => $this->key, 'redirect_uri' => $this->callback_url, 'state' => $request_token_id);
     $params = apply_filters('keyring_' . $this->get_name() . '_request_token_params', $params);
     Keyring_Util::debug('OAuth2 Redirect URL: ' . $url . _http_build_query($params, '', '&'));
     wp_redirect($url . _http_build_query($params, '', '&'));
     exit;
 }
开发者ID:humanmade,项目名称:keyring,代码行数:21,代码来源:oauth2.php

示例5: _get_rabobank_data

 function _get_rabobank_data($data, $tran_id)
 {
     // new data
     $n_data = array();
     // map
     $map = array('currencyCode' => 'currency', 'merchantId' => 'merchantID', 'normalReturnUrl' => 'urlSuccess', 'amount' => 'amount', 'transactionReference' => 'purchaseID', 'customerLanguage' => 'language', 'orderId' => 'purchaseID');
     // loop
     foreach ($map as $k => $v) {
         $n_data[$k] = $data[$v];
     }
     // date
     // $n_data['expirationDate']	    = $data['validUntil'];// date(DATE_ISO8601, strtotime('+1 hour'));
     // key version
     $n_data['keyVersion'] = $this->setting['key_version'];
     $n_data['paymentMeanBrandList'] = $this->setting['payment_mean_brand'];
     // current 4217 code
     $n_data['currencyCode'] = mgm_get_currency_iso4217($n_data['currencyCode']);
     $n_data['customerLanguage'] = substr($n_data['customerLanguage'], 0, 2);
     // url
     $n_data['automaticResponseUrl'] = site_url() . '/idealraboomnikassa_proxy.php?url_' . base64_encode(add_query_arg(array('extra' => $data['purchaseID']), $this->setting['notify_url']));
     $n_data['normalReturnUrl'] = site_url() . '/idealraboomnikassa_proxy.php?url_' . base64_encode(add_query_arg(array('extra' => $data['purchaseID']), $this->setting['return_url']));
     // convert = to %3D, rabo strips =
     // $n_data['automaticResponseUrl'] = str_replace('=', '%3D', $n_data['automaticResponseUrl']);
     // $n_data['normalReturnUrl']      = str_replace('=', '%3D', $n_data['normalReturnUrl']);
     // filter null
     $n_data = array_filter($n_data);
     // data string
     $data_str = _http_build_query($n_data, null, '|', '', false);
     $seal_str = $data_str . $this->setting['secret_key'];
     // seal
     $seal = hash('sha256', utf8_encode($seal_str));
     //computeSeal
     // interface
     $interface = 'HP_1.0';
     // return
     return array('Data' => $data_str, 'Seal' => $seal, 'InterfaceVersion' => $interface);
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:37,代码来源:mgm_ideal.php

示例6: request


//.........这里部分代码省略.........
  * Blocking mode really just means whether the fread should just pull what it can whenever it
  * gets bytes or if it should wait until it has enough in the buffer to read or finishes reading
  * the entire content. It doesn't actually always mean that PHP will continue going after making
  * the request.
  *
  * @access public
  * @since 2.7.0
  * @todo Refactor this code. The code in this method extends the scope of its original purpose
  *		and should be refactored to allow for cleaner abstraction and reduce duplication of the
  *		code. One suggestion is to create a class specifically for the arguments, however
  *		preliminary refactoring to this affect has affect more than just the scope of the
  *		arguments. Something to ponder at least.
  *
  * @param string $url URI resource.
  * @param str|array $args Optional. Override the defaults.
  * @return array containing 'headers', 'body', 'response', 'cookies'
  */
 function request($url, $args = array())
 {
     global $wp_version;
     $defaults = array('method' => 'GET', 'timeout' => apply_filters('http_request_timeout', 5), 'redirection' => apply_filters('http_request_redirection_count', 5), 'httpversion' => apply_filters('http_request_version', '1.0'), 'user-agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true);
     $r = wp_parse_args($args, $defaults);
     $r = apply_filters('http_request_args', $r, $url);
     // Allow plugins to short-circuit the request
     $pre = apply_filters('pre_http_request', false, $r, $url);
     if (false !== $pre) {
         return $pre;
     }
     $arrURL = parse_url($url);
     if ($this->block_request($url)) {
         return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
     }
     // Determine if this is a https call and pass that on to the transport functions
     // so that we can blacklist the transports that do not support ssl verification
     $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
     // Determine if this request is to OUR install of WordPress
     $homeURL = parse_url(get_bloginfo('url'));
     $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
     unset($homeURL);
     if (is_null($r['headers'])) {
         $r['headers'] = array();
     }
     if (!is_array($r['headers'])) {
         $processedHeaders = WP_Http::processHeaders($r['headers']);
         $r['headers'] = $processedHeaders['headers'];
     }
     if (isset($r['headers']['User-Agent'])) {
         $r['user-agent'] = $r['headers']['User-Agent'];
         unset($r['headers']['User-Agent']);
     }
     if (isset($r['headers']['user-agent'])) {
         $r['user-agent'] = $r['headers']['user-agent'];
         unset($r['headers']['user-agent']);
     }
     // Construct Cookie: header if any cookies are set
     WP_Http::buildCookieHeader($r);
     if (WP_Http_Encoding::is_available()) {
         $r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding();
     }
     if (empty($r['body'])) {
         // Some servers fail when sending content without the content-length header being set.
         // Also, to fix another bug, we only send when doing POST and PUT and the content-length
         // header isn't already set.
         if (($r['method'] == 'POST' || $r['method'] == 'PUT') && !isset($r['headers']['Content-Length'])) {
             $r['headers']['Content-Length'] = 0;
         }
         // The method is ambiguous, because we aren't talking about HTTP methods, the "get" in
         // this case is simply that we aren't sending any bodies and to get the transports that
         // don't support sending bodies along with those which do.
         $transports = WP_Http::_getTransport($r);
     } else {
         if (is_array($r['body']) || is_object($r['body'])) {
             if (!version_compare(phpversion(), '5.1.2', '>=')) {
                 $r['body'] = _http_build_query($r['body'], null, '&');
             } else {
                 $r['body'] = http_build_query($r['body'], null, '&');
             }
             $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
             $r['headers']['Content-Length'] = strlen($r['body']);
         }
         if (!isset($r['headers']['Content-Length']) && !isset($r['headers']['content-length'])) {
             $r['headers']['Content-Length'] = strlen($r['body']);
         }
         // The method is ambiguous, because we aren't talking about HTTP methods, the "post" in
         // this case is simply that we are sending HTTP body and to get the transports that do
         // support sending the body. Not all do, depending on the limitations of the PHP core
         // limitations.
         $transports = WP_Http::_postTransport($r);
     }
     do_action('http_api_debug', $transports, 'transports_list');
     $response = array('headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array());
     foreach ((array) $transports as $transport) {
         $response = $transport->request($url, $r);
         do_action('http_api_debug', $response, 'response', get_class($transport));
         if (!is_wp_error($response)) {
             return apply_filters('http_response', $response, $r, $url);
         }
     }
     return $response;
 }
开发者ID:steveh,项目名称:wordpress,代码行数:101,代码来源:http.php

示例7: build_url

 /**
  * Build URL with the specified parameters
  *
  * @param string $url
  * @param array $parameters
  * @return string
  */
 public static function build_url($url, array $parameters)
 {
     return $url . '?' . _http_build_query($parameters, null, '&');
 }
开发者ID:wp-pay,项目名称:core,代码行数:11,代码来源:Util.php

示例8: _http_build_query

/**
 * From php.net (modified by Mark Jaquith to behave like the native PHP5 function).
 *
 * @since 3.2.0
 * @access private
 *
 * @see http://us1.php.net/manual/en/function.http-build-query.php
 *
 * @param array|object  $data       An array or object of data. Converted to array.
 * @param string        $prefix     Optional. Numeric index. If set, start parameter numbering with it.
 *                                  Default null.
 * @param string        $sep        Optional. Argument separator; defaults to 'arg_separator.output'.
 *                                  Default null.
 * @param string        $key        Optional. Used to prefix key name. Default empty.
 * @param bool          $urlencode  Optional. Whether to use urlencode() in the result. Default true.
 *
 * @return string The query string.
 */
function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urlencode = true ) {
	$ret = array();

	foreach ( (array) $data as $k => $v ) {
		if ( $urlencode)
			$k = urlencode($k);
		if ( is_int($k) && $prefix != null )
			$k = $prefix.$k;
		if ( !empty($key) )
			$k = $key . '%5B' . $k . '%5D';
		if ( $v === null )
			continue;
		elseif ( $v === false )
			$v = '0';

		if ( is_array($v) || is_object($v) )
			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
		elseif ( $urlencode )
			array_push($ret, $k.'='.urlencode($v));
		else
			array_push($ret, $k.'='.$v);
	}

	if ( null === $sep )
		$sep = ini_get('arg_separator.output');

	return implode($sep, $ret);
}
开发者ID:nasrulhazim,项目名称:WordPress,代码行数:46,代码来源:functions.php

示例9: _create_paypal_profile

 /**
  * create recurring profile
  */
 function _create_paypal_profile()
 {
     // double check
     if ($_POST['RESULT'] != 0) {
         return;
     }
     // @todo
     // void the auth
     // $this->_void_auth();
     // tran
     $tran = mgm_get_transaction($_POST['M_CUSTOM']);
     // pack
     $pack = $tran['data'];
     // log
     // mgm_log($pack, $this->module . __FUNCTION__);
     // one time billing cycle
     if (isset($pack['num_cycles']) && (int) $pack['num_cycles'] == 1) {
         // log
         mgm_log('Exit Flag for One time billing', $this->module . __FUNCTION__);
         // exit
         return;
     }
     // log
     mgm_log('Process flag to Create Profile', $this->module . __FUNCTION__);
     // user data
     $user_id = $pack['user_id'];
     $user = get_userdata($user_id);
     // item
     $item = $this->get_pack_item($pack);
     // periods
     $pay_periods = array('d' => 'DAYS', 'w' => 'WEEK', 'm' => 'MONT', 'y' => 'YEAR');
     // day not supported by Paypal
     $pay_terms = array('d' => 365, 'w' => 52, 'm' => 12, 'y' => 1);
     // secured
     $secured = array('PARTNER' => $this->setting['partner'], 'VENDOR' => $this->setting['vendor'], 'USER' => $this->setting['username'], 'PWD' => $this->setting['password'], 'MAXFAILPAYMENTS' => (int) $this->setting['max_failed_payments']);
     // greater than 0, set term to ongoing
     if ((int) $pack['num_cycles'] > 1) {
         $term = $pay_terms[$pack['duration_type']] * ($pack['num_cycles'] - 1);
         // reduce 1 since auth captures first payment right away
     } else {
         $term = 0;
     }
     // exprs
     $duration_exprs = mgm_get_class('subscription_packs')->get_duration_exprs();
     //array('d'=>'DAY','w' => 'WEEK', 'm'=>'MONTH', 'y'=>'YEAR' );
     // start date should be next billing cycle date, //date('mdY', strtotime('+1 DAY')),//MMDDYYYY
     $start_date = date('mdY', strtotime('+' . 1 * (int) $pack['duration'] . ' ' . $duration_exprs[$pack['duration_type']]));
     // method
     switch ($_POST['METHOD']) {
         case 'CC':
             // Credit Card DCC
             // comment
             $comment = sprintf('%s By %s', $item['name'], $user->user_email);
             # code...
             $data = array('TRXTYPE' => 'R', 'TENDER' => 'C', 'ACTION' => 'A', 'PROFILENAME' => $item['name'], 'ORIGID' => $_POST['PNREF'], 'START' => $start_date, 'PAYPERIOD' => $pay_periods[$pack['duration_type']], 'TERM' => $term, 'AMT' => $pack['cost'], 'EMAIL' => $user->user_email, 'DESC' => $item['name'], 'COMMENT1' => $this->_remove_special_chars($comment));
             break;
         case 'P':
             // PayPal, EC
         // PayPal, EC
         default:
             // comment
             $comment = sprintf('%s By %s', $item['name'], $user->user_email);
             # code...
             $data = array('TRXTYPE' => 'R', 'TENDER' => 'P', 'ACTION' => 'A', 'PROFILENAME' => $item['name'], 'BAID' => isset($_POST['BAID']) && !empty($_POST['BAID']) ? $_POST['BAID'] : $_POST['PNREF'], 'START' => $start_date, 'PAYPERIOD' => $pay_periods[$pack['duration_type']], 'TERM' => $term, 'AMT' => $pack['cost'], 'EMAIL' => $user->user_email, 'DESC' => $item['name'], 'COMMENT1' => $this->_remove_special_chars($comment));
             // check, notify admin
             if (!isset($_POST['BAID']) || empty($_POST['BAID'])) {
                 // subject
                 $subject = 'BAID missing in PayPal Payflow Profile Creation';
                 // message
                 $message = sprintf('BAID missing in PayPal Payflow Profile Creation, Please contact PayPal, POST DATA: %s', print_r($_POST, true));
                 // send
                 mgm_notify_admin(null, $subject, $message);
                 // log
                 mgm_log($message, $this->module . __FUNCTION__);
             }
             break;
     }
     // additional fields
     $this->_set_address_fields($user, $data);
     // merge
     $data = array_merge($secured, $data);
     // log
     mgm_log($data, $this->module . __FUNCTION__);
     // data
     $data_post = _http_build_query($data, null, '&', '', false);
     // do not encode
     // link
     $post_url = $this->_get_endpoint();
     //issue #1508
     $url_parsed = parse_url($post_url);
     // domain/host
     $domain = $url_parsed['host'];
     // headers
     $http_headers = array('POST /cgi-bin/webscr HTTP/1.1\\r\\n', 'Content-Type: application/x-www-form-urlencoded\\r\\n', 'Host: ' . $domain . '\\r\\n', 'Connection: close\\r\\n\\r\\n');
     // post
     $http_response = mgm_remote_post($post_url, $data_post, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
     // parse
//.........这里部分代码省略.........
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_paypalpayflow.php

示例10: request


//.........这里部分代码省略.........
	 * @param string $url URI resource.
	 * @param str|array $args Optional. Override the defaults.
	 * @return array containing 'headers', 'body', 'response', 'cookies'
	 */
	function request( $url, $args = array() ) {
		global $wp_version;

		$defaults = array(
			'method' => 'GET',
			'timeout' => apply_filters( 'http_request_timeout', 5),
			'redirection' => apply_filters( 'http_request_redirection_count', 5),
			'httpversion' => apply_filters( 'http_request_version', '1.0'),
			'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )  ),
			'blocking' => true,
			'headers' => array(),
			'cookies' => array(),
			'body' => null,
			'compress' => false,
			'decompress' => true,
			'sslverify' => true
		);

		$r = wp_parse_args( $args, $defaults );
		$r = apply_filters( 'http_request_args', $r, $url );

		$arrURL = parse_url($url);

		if ( $this->block_request( $url ) )
			return new WP_Error('http_request_failed', 'User has blocked requests through HTTP.');

		// Determine if this is a https call and pass that on to the transport functions
		// so that we can blacklist the transports that do not support ssl verification
		$r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';

		// Determine if this request is to OUR install of WordPress
		$homeURL = parse_url(get_bloginfo('url'));
		$r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
		unset($homeURL);

		if ( is_null( $r['headers'] ) )
			$r['headers'] = array();

		if ( ! is_array($r['headers']) ) {
			$processedHeaders = WP_Http::processHeaders($r['headers']);
			$r['headers'] = $processedHeaders['headers'];
		}

		if ( isset($r['headers']['User-Agent']) ) {
			$r['user-agent'] = $r['headers']['User-Agent'];
			unset($r['headers']['User-Agent']);
		}

		if ( isset($r['headers']['user-agent']) ) {
			$r['user-agent'] = $r['headers']['user-agent'];
			unset($r['headers']['user-agent']);
		}

		// Construct Cookie: header if any cookies are set
		WP_Http::buildCookieHeader( $r );

		if ( WP_Http_Encoding::is_available() )
			$r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding();

		if ( is_null($r['body']) ) {
			// Some servers fail when sending content without the content-length
			// header being set.
			$r['headers']['Content-Length'] = 0;
			$transports = WP_Http::_getTransport($r);
		} else {
			if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) {
				if ( ! version_compare(phpversion(), '5.1.2', '>=') )
					$r['body'] = _http_build_query($r['body'], null, '&');
				else
					$r['body'] = http_build_query($r['body'], null, '&');
				$r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
				$r['headers']['Content-Length'] = strlen($r['body']);
			}

			if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) )
				$r['headers']['Content-Length'] = strlen($r['body']);

			$transports = WP_Http::_postTransport($r);
		}

		if ( has_action('http_api_debug') )
			do_action('http_api_debug', $transports, 'transports_list');

		$response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
		foreach ( (array) $transports as $transport ) {
			$response = $transport->request($url, $r);

			if ( has_action('http_api_debug') )
				do_action( 'http_api_debug', $response, 'response', get_class($transport) );

			if ( ! is_wp_error($response) )
				return $response;
		}

		return $response;
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:http.php

示例11: _create_upgrade_enc

 function _create_upgrade_enc($pack, $data, $tran_id)
 {
     // get member
     $member = mgm_get_member($pack['user_id']);
     // copy
     $enc_data = array();
     // check
     if (isset($member->payment_info->subscr_id) && !empty($member->payment_info->subscr_id)) {
         // set
         $enc_data['subscriptionId'] = $member->payment_info->subscr_id;
         $enc_data['upgradeClientAccnum'] = $data['clientAccnum'];
         $enc_data['upgradeClientSubacc'] = $data['clientSubacc'];
         // return base64_encode();
         if (isset($pack['product']['ccbill_substype_id']) && !empty($pack['product']['ccbill_substype_id'])) {
             // set
             $enc_data['upgradeTypeId'] = trim($pack['product']['ccbill_substype_id']);
             // custom passthrough
             $enc_data['custom'] = $tran_id;
             // str
             $enc_str = _http_build_query($enc_data, null, '&', '', false);
             // enc
             return $enc = $this->encrypt($enc_str, $this->setting['upgrade_enc_key']);
         }
     } else {
         $this->enc_error = __('Member has no active CCBill Subscription, failed to process upgrade', 'mgm');
     }
     // return
     return '';
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:29,代码来源:mgm_ccbill.php

示例12: _get_postfields

 /**
  * API helper method get post fields
  *
  * @param none
  * @return string $postfields
  */
 function _get_postfields($user_id)
 {
     // new filter
     $this->postfields = apply_filters('mgm_autoresponder_get_postfields', $this->postfields, $this->code, $user_id);
     // check
     if (is_array($this->postfields)) {
         // return
         return _http_build_query($this->postfields, null, '&', '', true);
     } elseif (is_string($this->postfields)) {
         // return
         return $this->postfields;
     }
     // return as it is
     return $this->postfields;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:21,代码来源:mgm_autoresponder.php

示例13: _http_build_query

 function _http_build_query($formdata, $numeric_prefix = '', $key_prefix = '')
 {
     if ($numeric_prefix != '' && !is_numeric($numeric_prefix)) {
         $prefix = $numeric_prefix;
     } else {
         $prefix = '';
     }
     if (!is_array($formdata)) {
         return '';
     }
     $str = '';
     foreach ($formdata as $key => $val) {
         if (is_numeric($key)) {
             $key = $prefix . $key;
         }
         if ($str != '') {
             $str .= '&';
         }
         if ($key_prefix != '') {
             $mykey = $key_prefix . "[{$key}]";
         } else {
             $mykey =& $key;
         }
         if (is_array($val)) {
             $str .= _http_build_query($val, '', $mykey);
         } else {
             $str .= $mykey . '=' . urlencode($val);
         }
     }
     return $str;
 }
开发者ID:Artea,项目名称:freebeer,代码行数:31,代码来源:Backport.php

示例14: five_remote_get

/**
 * Retrieve the raw response from the HTTP request using the GET method.
 *
 * @see wp_remote_request() For more information on the response array format.
 *
 * @since 2.7.0
 *
 * @param string $url Site URL to retrieve.
 * @param array $args Optional. Override the defaults.
 * @return WP_Error|array The response or WP_Error on failure.
 */
function five_remote_get($url, $args = array())
{
    //initializing
    $defaults = array('method' => 'POST', 'timeout' => apply_filters('http_request_timeout', 5), 'redirection' => apply_filters('http_request_redirection_count', 5), 'httpversion' => apply_filters('http_request_version', '1.0'), 'user-agent' => apply_filters('http_headers_useragent', '5TwentyStudiosCMS/1.0; http://www.5twentystudios.com'), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true);
    $r = five_parse_args($args, $defaults);
    $r = apply_filters('http_request_args', $r, $url);
    // Allow plugins to short-circuit the request
    $pre = apply_filters('pre_http_request', false, $r, $url);
    if (false !== $pre) {
        return $pre;
    }
    $fiveConfig = fiveConfigurations();
    $arrURL = parse_url($url);
    if (empty($url) || empty($arrURL['scheme'])) {
        return array('error' => 'http_request_insufficient_data', '' => 'A valid URL was not provided.');
    }
    // Determine if this is a https call and pass that on to the transport functions
    // so that we can blacklist the transports that do not support ssl verification
    $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
    // Determine if this request is to OUR install of WordPress
    $homeURL = parse_url($fiveConfig->base->url);
    $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
    unset($homeURL);
    if (is_null($r['headers'])) {
        $r['headers'] = array();
    }
    if (!is_array($r['headers'])) {
        $processedHeaders = BCurl::processHeaders($r['headers']);
        $r['headers'] = $processedHeaders['headers'];
    }
    if (isset($r['headers']['User-Agent'])) {
        $r['user-agent'] = $r['headers']['User-Agent'];
        unset($r['headers']['User-Agent']);
    }
    if (isset($r['headers']['user-agent'])) {
        $r['user-agent'] = $r['headers']['user-agent'];
        unset($r['headers']['user-agent']);
    }
    if (BCurl::encoding_is_available()) {
        $r['headers']['Accept-Encoding'] = BCurl::accept_encoding();
    }
    if (empty($r['body'])) {
        $r['body'] = null;
        // Some servers fail when sending content without the content-length header being set.
        // Also, to fix another bug, we only send when doing POST and PUT and the content-length
        // header isn't already set.
        if (($r['method'] == 'POST' || $r['method'] == 'PUT') && !isset($r['headers']['Content-Length'])) {
            $r['headers']['Content-Length'] = 0;
        }
    } else {
        if (is_array($r['body']) || is_object($r['body'])) {
            if (!version_compare(phpversion(), '5.1.2', '>=')) {
                $r['body'] = _http_build_query($r['body'], null, '&');
            } else {
                $r['body'] = http_build_query($r['body'], null, '&');
            }
            $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
            $r['headers']['Content-Length'] = strlen($r['body']);
        }
        if (!isset($r['headers']['Content-Length']) && !isset($r['headers']['content-length'])) {
            $r['headers']['Content-Length'] = strlen($r['body']);
        }
    }
    //finally..  make the request
    $bcurl = new BCurl();
    $response = $bcurl->request($url, $r);
    return $response;
}
开发者ID:Jonathonbyrd,项目名称:5TwentyCMS,代码行数:79,代码来源:request.php

示例15: build_query

 /**
  * Essentially a copy of WP's build_query but one that doesn't expect pre-urlencoded values.
  *
  * @param array $args An array of key => value pairs
  * @return string A string ready for use as a URL query string.
  */
 public static function build_query($args)
 {
     return _http_build_query($args, '', '&');
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:10,代码来源:class.akismet.php


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