Created
May 20, 2012 02:50
-
-
Save sergej-brazdeikis/2736455 to your computer and use it in GitHub Desktop.
vk.com video search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Search video library by title | |
| * @var $title string | |
| * @return array List of videos | |
| */ | |
| public function search($title) | |
| { | |
| $html = $this->gb->get('http://vk.com/video?q='.htmlentities(urlencode($title)).'§ion=search'); | |
| if(!$this->checkResponse($html)) | |
| return '<error>Unable to login</error>'; | |
| $items = $this->gb->preg()->getAll( | |
| "/\[([-]?[\d]*), ([\d]*), '([^']*)', '([^']*)', '[^']*', '[^']*', [\d]*, [\d]*, [\d]*, '([^']*)'/", | |
| $html); | |
| if(empty($items)) return array(); | |
| $output = array(); | |
| foreach($items as $item) | |
| { | |
| $output[] = array( | |
| 'id1' => $item[0], | |
| 'id2' => $item[1], | |
| 'imageLink' => str_replace('\/','/', $item[2]), | |
| 'title' => $item[3], | |
| 'duration' => $item[4], | |
| ); | |
| } | |
| return $output; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment