콩짜개 인터넷 영화 정 보 를 얻 기 위 한 안내

31664 단어 간단 한 소개
<?php

//    

function search_link($moviename)

{

        

        //  url,  max-results       

        $urlString = 'http://api.douban.com/movie/subjects?q='.$moviename.'&start-index=1&max-results=1&alt=json';

        //print_r($urlString);

        $urlString=mb_convert_encoding($urlString, "UTF-8", "GBK");// Url   utf-8  

        $r = new HttpRequest($urlString,HttpRequest::METH_GET);//  

        $response = $r->send();

        $result = $r->getResponseBody();

        $obj = json_decode($result);//   json  

    

        if($entry = @$obj->{'entry'}){

                //            

                for($i = 0;$i<sizeof($entry);$i++){

                        $link=$entry[$i]->{'link'}; 

                        for($j = 0;$j<sizeof($link);$j++){

                              $arr = (array)$link[$j];

                              $key = array_search("self",$arr);

                              if($key){                                    //  key    

                                  $str = $arr["@href"].'?alt=json'; //         

                                  break;

                              }    

                        }

                        $link_array[] = $str;

                }

                return $link_array;//    

        } else

                echo"Not Found!";

        

}



//           $GLOBAL   

function get_info($urlString)

{

        $r = new HttpRequest($urlString,HttpRequest::METH_GET);

        $response = $r->send();

        $result = $r->getResponseBody();

        

        //if..else..           

        if ($obj = json_decode($result)){

            //             

            $title = $obj->{'title'};

            $author = $obj->{'author'};

            $summary = $obj->{'summary'};

            $ID=$obj->{'id'};

            $link = $obj->{'link'};  

            $gd = (array)$obj->{'gd:rating'};    

            $db_array = array();

            

            $db = $obj->{'db:attribute'};

            // db:atribute       

            foreach ($db as $value){

                $value_array = (array)($value);



                $v = $value_array["@name"];

                $k = $value_array["\$t"];

                if (array_key_exists("@lang",$value_array)){

                    $lang=$value_array["@lang"];

                    $k=$k.'['.$lang.']';

                }        

                $db_array[$v][]=$k; 

            }

            //         

            @$db_array_key = array('【    】','【      】','【      】','【      】','【    】','【IMDB  】','【    】',

                               '【      】','【    】','【    】','【    】','【      】','【      】','【      】');

            @$db_array_value = array($db_array["title"],$db_array["aka"],$db_array["director"],$db_array["writer"],$db_array["website"],

                                 $db_array["imdb"],$db_array["year"],$db_array["country"],$db_array["movie_type"],$db_array["pubdate"],

                                 $db_array["movie_duration"],$db_array["episodes"],$db_array["language"],$db_array["cast"]);

            @$db_array = array_combine($db_array_key,$db_array_value);

        }   else{

                echo "Empty link!";

        }

        $info=array("title"=>$title,"author"=>$author,"summary"=>$summary,"ID"=>$ID,"link"=>$link,"gd"=>$gd,"db_array"=>$db_array);

        return $info;

}

//                 

function write_info($fi,$info)            

{  

            //fwrite($fi, "******");    

            fwrite($fi, "【    】");

            foreach ($info["title"] as $k=>$v)

                    fwrite($fi,"$v\r
"); fwrite($fi,"\r
"); fwrite($fi,"【 】"); foreach ($info["author"] as $value) foreach ($value as $key) foreach ($key as $v) { fwrite($fi,"$v\r
"); } fwrite($fi,"\r
"); //db:attribute foreach ($info["db_array"] as $key=>$value){ if(count($value)){ fwrite($fi,$key); if($value==$info["db_array"]['【 】']){ foreach($value as $k=>$v) fwrite($fi,"$v\r
"); } else{ foreach($value as $k=>$v) fwrite($fi,"$v "); fwrite($fi,"\r
"); } } } fwrite($fi,"\r
"); // fwrite($fi, "【 】\r
"); foreach ($info["summary"] as $k=>$v){ fwrite($fi," $v \r
"); } fwrite($fi,"\r
"); //ID fwrite($fi,"【I D】"); foreach ($info["ID"] as $k=>$v){ fwrite($fi,$v); } fwrite($fi,"\r
"); // fwrite($fi,"【 】\r
"); foreach ($info["link"] as $value){ foreach ($value as $k=>$v){ fwrite($fi, " $v "); } fwrite($fi,"\r
"); } fwrite($fi,"\r
"); // fwrite($fi,'【 】'); fwrite($fi,$info["gd"]["@numRaters"]); fwrite($fi,"\r
"); fwrite($fi,'【 】'); fwrite($fi,$info["gd"]["@max"]); fwrite($fi," 【 】");fwrite($fi,$info["gd"]["@min"]); fwrite($fi,' 【 】');fwrite($fi, $info["gd"]["@average"]); fwrite($fi,"\r
"); } // function find_dir($dir) { if(is_dir($dir)){ // if($fdir=opendir($dir)){ // while(false!==($file=readdir($fdir))){ // if ($file != "." && $file != "..") $files[]=$file; // } closedir($fdir); print_r($file); return $files; } } } // txt function write_to_dir($dir,$moviename) { if (is_dir($dir)){ // if($fdir=opendir($dir)){ // while(false!==($file=readdir($fdir))){ // if ($file != '.' && $file != '..') { $dirname=$dir.'\\'.$file; if (is_dir($dirname)&&$file==$moviename) { // $filename=$dirname.'\\'.$moviename.'.txt'; //if(!file_exists($filename)){ if($fi=fopen($filename,'w+')){ // , , closedir($fdir); return $fi; }else echo"Fail to Open file!"; //} } else echo "Dir Not Exists!"; } } } else { echo 'Fail to Open!'; return; } } else { echo 'Directory Not Exists!'; return; } } $dir = 'E:\film'; if($movienames = @find_dir($dir)){ // foreach ($movienames as $key=>$moviename){ if($link_info = search_link($moviename)){ // if ($fi=write_to_dir($dir,$moviename)){ // fwrite($fi,"<Resources>\r
"); fwrite($fi,'<MesageBody>'); fwrite($fi,"\r
\r
\r
".'※※※※※※※※※※※※※※※※※※※※※   ※※※※※※※※※※※※※※※※※※※※※'."\r
"); foreach ($link_info as $k){ $info=get_info($k); // write_info($fi,$info); // txt fwrite($fi,"*************************************************************************************************\r
"); } fclose($fi);// } } else echo "Empty!"; } } else echo "Movies Not Exists!"; ?>

Fatal error: Class ‘HttpRequest’ not found
코드 가 있 습 니 다:
$httpRequest = new HttpRequest($oauthRequest->http_url(), HttpRequest::METH_GET);
HttpRequest 같은 종류 가 없습니다. php 확장 문제 입 니 다.
wamp > php 설정 php 확장 추가 확장 입력 phphttp. dll 리 턴

좋은 웹페이지 즐겨찾기