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


PHP OAuthUtil::encodeUrlEncodedArray方法代码示例

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


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

示例1: to_postdata

	/**
	 * builds the data one would send in a POST request
	 *
	 *
	 */
	public function to_postdata() {
		//we can probably take this level of indirection out
		//	the function urlencodeArray seemed more like a utily/ static sort of function
		//	so i moved it there
		 
		$out = OAuthUtil::encodeUrlEncodedArray($this->parameters);
		return $out;
	}
开发者ID:hoalangoc,项目名称:ftf,代码行数:13,代码来源:OAuth.php

示例2: makeHttpRequest

 /**
  *  this function will make a raw HTTP requests using PHP's cURL
  *
  *  //maybe? make* functions should always be called with a try(){}catch(){}
  */
 private function makeHttpRequest($method, $url, $qParams, $headers = array(), $bodyContent = NULL)
 {
     $datetime = new DateTime();
     $datetime = $datetime->format(DATE_ATOM);
     if (self::$MS_DUMP_REQUESTS) {
         $dump = "\r\n";
         $dump .= '::makeHttpRequest::@' . $datetime . "\r\n";
         $dump .= "_____________________________________________\r\n";
         $dump .= '::reqUrl::\'' . $method . '\'  ' . $url . "\r\n";
         $dump .= '::reqParams::' . OAuthUtil::encodeUrlEncodedArray($qParams) . "\r\n";
         $dump .= '::custom headers::' . "\r\n";
         foreach ($headers as $key => $value) {
             $dump .= $key . ': ' . $value . "\r\n";
         }
         $dump .= "\r\n";
         $dump .= '::bodyContent::' . "\r\n";
         $dump .= $bodyContent;
         self::dump($dump);
     }
     //this url, may or may not have signed params on it already,
     //if it does, we may not want more params
     //hmmm what about the body content being signed?
     if (!self::isSupportedMethod($method)) {
         //raise error, unsupported request method
     }
     //not sure if this is needed yet
     $url_bits = parse_url($url);
     $req_url = $url_bits['path'];
     if (empty($bodycontent)) {
         //if we are doing a GET, the query params need to be in the request url
         //maybe for DELETE too?
         //still not sure about this
         if ($url_bits['query']) {
             $req_url .= '?' . $url_bits['query'];
         }
     }
     //init curl
     $ch = curl_init();
     /**
      *@link http://us.php.net/manual/en/function.curl-setopt.php
      */
     //something related to CURLOP_SSL_VERIFYPEER, and validating certs from local a local path
     if (defined("CURL_CA_BUNDLE_PATH")) {
         curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH);
     }
     //sets the url we are going to make a request from
     //this is the full $url from the function call
     curl_setopt($ch, CURLOPT_URL, $url);
     //The number of seconds to wait whilst trying to connect. Use 0 to wait indefinitely
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
     //The maximum number of seconds to allow cURL functions to execute.
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     //TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     //setup the headers
     $h = array();
     foreach ($headers as $k => $v) {
         $h[] = $k . ": " . $v;
     }
     curl_setopt($ch, CURLOPT_HEADER, true);
     //ok, now we need to worry about POST, and PUTs
     switch ($method) {
         case 'GET':
             //we do not need to do anything
             break;
         case 'POST':
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
             //The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value.
             curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyContent);
             //does this work with UTF-8 chars?
             //$h[] = 'Content-Length: ' . strlen($bodyContent);
             break;
         case 'PUT':
             //if we are going to put a file,
             //this needs to be done differently
             //this is designed for small url encoded strings
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
             //The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value.
             curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyContent);
             //$h[] = 'Content-Length: ' . strlen($bodyContent);
             break;
         case 'DELETE':
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
     }
     self::dump("\r\n" . '::Sent Headers::' . "\r\n" . implode("\r\n", $h));
     curl_setopt($ch, CURLOPT_HTTPHEADER, array(implode("\r\n", $h)));
     $myspace_response = curl_exec($ch);
     $responseBody = '';
     $responseHeader = '';
     list($responseHeader, $responseBody) = explode("\r\n\r\n", $myspace_response, 2);
     $responseStatus = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $responseContentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
     //if a content type was found
     if ($responseContentType) {
//.........这里部分代码省略.........
开发者ID:phonglanpls,项目名称:jz-proj-2012,代码行数:101,代码来源:myspace.php


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