本文整理汇总了PHP中OAuthUtil::boundary方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthUtil::boundary方法的具体用法?PHP OAuthUtil::boundary怎么用?PHP OAuthUtil::boundary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuthUtil
的用法示例。
在下文中一共展示了OAuthUtil::boundary方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_http_query_multi
public static function build_http_query_multi($params)
{
if (!$params) {
return '';
}
//print_r( $params );
//return null;
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
//if( $parameter == 'pic' && $value{0} == '@' )
if (in_array($parameter, array("pic", "image"))) {
/*
$tmp = 'E:\qweibo_proj\trunk\1.txt';
$url = ltrim($tmp,'@');
$content = file_get_contents( $url );
$filename = reset( explode( '?' , basename( $url ) ));
$mime = self::get_image_mime($url);
*/
//$url = ltrim( $value , '@' );
$content = $value[2];
//file_get_contents( $url );
$filename = $value[1];
//reset( explode( '?' , basename( $url ) ));
$mime = $value[0];
//self::get_image_mime($url);
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
$multipartbody .= 'Content-Type: ' . $mime . "\r\n\r\n";
$multipartbody .= $content . "\r\n";
} else {
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
$multipartbody .= $value . "\r\n";
}
}
$multipartbody .= "{$endMPboundary}\r\n";
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return $multipartbody;
}
示例2: build_http_query_multi
public static function build_http_query_multi($params)
{
if (!$params) {
return '';
}
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
if (in_array($parameter, array("pic", "image")) && $value[0] == '@') {
$url = ltrim($value, '@');
$content = file_get_contents($url);
$filename = reset(explode('?', basename($url)));
$mime = self::get_image_mime($url);
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
$multipartbody .= 'Content-Type: ' . $mime . "\r\n\r\n";
$multipartbody .= $content . "\r\n";
} else {
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'content-disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
$multipartbody .= $value . "\r\n";
}
}
$multipartbody .= $endMPboundary;
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
// echo $multipartbody;
return $multipartbody;
}
示例3: build_http_query_multi
public static function build_http_query_multi($params)
{
if (!$params) {
return '';
}
//print_r( $params );
//return null;
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
//if( $parameter == 'pic' && $value{0} == '@' )
if (in_array($parameter, array("pic", "image"))) {
$content = $value;
$filename = 'pic.jpg';
$mime = 'image/jpeg';
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
$multipartbody .= 'Content-Type: ' . $mime . "\r\n\r\n";
$multipartbody .= $content . "\r\n";
} else {
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'content-disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
$multipartbody .= $value . "\r\n";
}
}
$multipartbody .= $endMPboundary . "\r\n";
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
// echo $multipartbody;
return $multipartbody;
}
示例4: build_http_query_multi
public static function build_http_query_multi($params)
{
if (!$params) {
return '';
}
//print_r( $params );
//return NULL;
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
if (in_array($parameter, array('pic', 'image')) && $value[0] == '@') {
$url = ltrim($value, '@');
$content = file_get_contents($url);
$array = explode('?', basename($url));
$filename = $array[0];
$mime = self::get_image_mime($url);
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
$multipartbody .= 'Content-Type: ' . $mime . "\r\n\r\n";
$multipartbody .= $content . "\r\n";
} else {
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'content-disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
$multipartbody .= $value . "\r\n";
}
/*
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
natsort($value);
foreach ($value as $duplicate_value) {
$pairs[] = $parameter . '=' . $duplicate_value;
}
} else {
$pairs[] = $parameter . '=' . $value;
}*/
}
$multipartbody .= $endMPboundary;
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
// echo $multipartbody;
return $multipartbody;
}
示例5: build_http_query_multi
public static function build_http_query_multi($params)
{
if (!$params) {
return '';
}
$keys = array_keys($params);
$values = array_values($params);
$params = array_combine($keys, $values);
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
if (in_array($parameter, array("pic", "image"))) {
if (is_array($value)) {
$content = $value[2];
$filename = $value[1];
$mime = $value[0];
} elseif ($value[0] == '@') {
$url = ltrim($value, '@');
$content = file_get_contents($url);
$filename = reset(explode('?', basename($url)));
$mime = self::get_image_mime($url);
}
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
$multipartbody .= 'Content-Type: ' . $mime . "\r\n\r\n";
$multipartbody .= $content . "\r\n";
} else {
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
$multipartbody .= $value . "\r\n";
}
}
$multipartbody .= "{$endMPboundary}\r\n";
return $multipartbody;
}
示例6: build_http_query_multi
public static function build_http_query_multi($params)
{
if (!$params) {
return '';
}
//print_r( $params );
//return null;
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $GLOBALS['__CLASS']['OAuthRequest']['__STATIC']['boundary'] = $boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
if ($parameter == 'pic' || $parameter == 'image') {
if (is_string($value) && $value[0] == '@') {
$url = ltrim($value, '@');
//��ʱ����
$ctx_userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 3.5.30729)';
if (version_compare(PHP_VERSION, '5.0.0', '>=')) {
$ctx_header = "Accept: *" . "/" . "*\r\nAccept-Language: zh-cn\r\nUser-Agent: {$ctx_userAgent}\r\n";
$ctx = stream_context_create(array('http' => array('timeout' => 8, 'method' => 'GET', 'header' => $ctx_header)));
$content = file_get_contents($url, 0, $ctx);
} else {
@ini_set('user_agent', $ctx_userAgent);
$content = file_get_contents($url);
}
$filename = reset(explode('?', basename($url)));
$mime = OAuthUtil::get_image_mime($url);
} elseif (is_array($value)) {
$content = $value[2];
//file_get_contents( $url );
$filename = $value[1];
//reset( explode( '?' , basename( $url ) ));
$mime = $value[0];
//self::get_image_mime($url);
}
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
$multipartbody .= 'Content-Type: ' . $mime . "\r\n\r\n";
$multipartbody .= $content . "\r\n";
} else {
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
$multipartbody .= $value . "\r\n";
}
}
$multipartbody .= "{$endMPboundary}\r\n";
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
// echo $multipartbody;
return $multipartbody;
}