
<?php
/*
返回:
array
'mp4'=>string'?K=48daa69002023a2a2828f4f1'(length=167)
if(string.length >,从而使用进入到错误处理中。namespace mvcmusicstore.helpers{ public static class htmlhelpers {public static string truncate(this htmlhelper helper, string input, int length){if (input.length <= length){return input。 'string' => string 'test string' (length=11)。
*/
if(YoukuFlv::getYoukuFlv(""))
{
var_dump(YoukuFlv::result());
}
else
{
echoYoukuFlv::error();
}
/*
获取优酷视频地址
*/
classYoukuFlv{
staticprivate$error="";
staticprivate$result=array();

staticpublicfunctiongetYoukuFlv($url){
//从url获取youkuid
if(!$id=self::getYoukuId($url)){
returnfalse;
}
//获取youku视频详细信息
$content=self::get_curl_contents("".$id);
$data=json_decode($content);
if(!isset($data->data[0]->streamfileids)){
self::$error="Cannotfindthisvideo";
returnfalse;
}
foreach($data->data[0]->streamfileidsAS$k=>$v){
if($k=='flv'||$k=='mp4'){
//sid
$sid=self::getSid();
//fileid
$fileid=self::getfileid($v,$data->data[0]->seed);
$one=($data->data[0]->segs->$k);
self::$result[$k]="{$sid}_00/st/{$k}/fileid/{$fileid}?K={$one[0]->k}";
}

}
if(empty(self::$result)){
self::$error="THISVIODISNOTINMP4ORFLVFORMAT";
returnfalse;
}else{
returntrue;
}
}
staticpublicfunctionerror(){
returnself::$error;
}
staticpublicfunctionresult(){
returnself::$result;
}
staticprivatefunctiongetYoukuId($url){
//url不能为空
if($url==""||substr($url,0,29)!=""){
self::$error="URLISERROR";
returnfalse;
}
returnsubstr($url,29,-5);

}
yesterday morning, menghai county meng town of nam long river village villagers zhu mou seven groups of villagers groups in their tents have been give the fatal attack, this is the town the second attack villagers mastodon death events.。2007-5-5 16:48:08 上传[url]下载附件 (157.57 kb)[/url]2007-5-5 16:48:08 上传[url]下载附件 (41.34 kb)[/url]。2007-5-5 16:48:08 上传[url]下载附件 (158.42 kb)[/url]2007-5-5 16:48:08 上传[url]下载附件 (59.43 kb)[/url]。
在php.ini里把 extension=php_curl.dll前面的分号去掉之后。php开启curl方法主要用到三个文件libeay32.dll,php_curl.dll,ssleay32.dll。在php.ini中找到有extension=php_curl.dll, 去掉前面的注释.。
$c=curl_init();
curl_setopt($c,CURLOPT_URL,$url);
$UserAgent=$_SERVER['HTTP_USER_AGENT'];
curl_setopt($c,CURLOPT_USERAGENT,$UserAgent);
curl_setopt($c,CURLOPT_HEADER,0);
curl_setopt($c,CURLOPT_TIMEOUT,$second);
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
$cnt=curl_exec($c);
curl_close($c);
return$cnt;
}
staticprivatefunctiongetSid(){
$sid=time().(rand(0,9000)+10000);
return$sid;
}
staticprivatefunctiongetfileid($fileId,$seed){
$mixed=self::getMixString($seed);
$ids=explode("*",$fileId);

unset($ids[count($ids)-1]);
$realId="";
for($i=0;$i<count($ids);++$i){
$idx=$ids[$i];
$realId.=substr($mixed,$idx,1);
}
return$realId;
}
staticprivatefunctiongetMixString($seed){
$mixed="";
$source="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890";
$len=strlen($source);
for($i=0;$i<$len;++$i){
$seed=($seed*211+30031)%65536;
$index=($seed/65536*strlen($source));
$c=substr($source,$index,1);
$mixed.=$c;
$source=str_replace($c,"",$source);
}
return$mixed;
}
}
?>
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/bofangqi/article-109873-1.html
一问怎么回事说分销商不送RIO了