Created
February 10, 2012 16:05
-
-
Save aminin/1790498 to your computer and use it in GitHub Desktop.
Генератор рекламного API ВКонтакте.
This file contains 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 | |
$naseUrl = 'http://vk.com/'; | |
$apiDocUrl = 'http://vk.com/developers.php?o=-1&p=Ads_API'; | |
$apiDoc = file_get_contents($apiDocUrl); | |
$apiDoc = iconv('windows-1251', 'utf-8', $apiDoc); | |
preg_match_all( | |
"~\<div class=\"wk_sub_header\"\>(?P<doc>.*?)\<\/div\>\s*\<ul class=\"listing\"\>(?P<methods>[\s\S]*?)\<\/ul\>~", | |
$apiDoc, | |
$matches, | |
PREG_SET_ORDER | |
); | |
echo "<?php\n"; | |
echo "class AdsService\n"; | |
echo "{\n"; | |
foreach ($matches as $match) { | |
$commonDoc = $match['doc']; | |
echo " /**#@+\n"; | |
echo " * $commonDoc\n"; | |
echo " */\n"; | |
preg_match_all( | |
"~\<li\>\<span\>\<a href=\"(?P<see>.*?)\">ads\.(?P<name>.*?)\<\/a\> — (?P<doc>.*?)\<\/span\>\<\/li\>~", | |
$match['methods'], | |
$methods, | |
PREG_SET_ORDER | |
); | |
foreach ($methods as $method) { | |
echo " /**\n"; | |
echo " * {$method['doc']}\n"; | |
echo " *\n"; | |
echo " * @see {$naseUrl}{$method['see']}\n"; | |
echo " */\n"; | |
echo " public function {$method['name']}()\n"; | |
echo " {\n"; | |
echo " }\n"; | |
echo "\n"; | |
} | |
echo " /**#@-*/\n\n"; | |
} | |
echo "}\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment