Skip to content

Instantly share code, notes, and snippets.

@sergej-brazdeikis
Created May 20, 2012 02:50
Show Gist options
  • Save sergej-brazdeikis/2736455 to your computer and use it in GitHub Desktop.
Save sergej-brazdeikis/2736455 to your computer and use it in GitHub Desktop.
vk.com video search
<?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)).'&section=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