本文整理汇总了PHP中OAuthUtil::get_image_mime方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthUtil::get_image_mime方法的具体用法?PHP OAuthUtil::get_image_mime怎么用?PHP OAuthUtil::get_image_mime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuthUtil
的用法示例。
在下文中一共展示了OAuthUtil::get_image_mime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = $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;
}