Skip to content

Instantly share code, notes, and snippets.

@bytepicker
Created March 11, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytepicker/1e4a008eddb366aa9d4c to your computer and use it in GitHub Desktop.
Save bytepicker/1e4a008eddb366aa9d4c to your computer and use it in GitHub Desktop.
<?php
$url = 'https://api.vk.com/method/wall.get?owner_id=183123381&count=1&filter="owner"';
$jsonFile = file_get_contents($url);
// convert the string to a json object
$jfo = json_decode($jsonFile, true);
$textWall = $jfo['response'][1]['text'];
// get number of poems
$numCount = $jfo['response'][0];
$randOffset = rand(1,$numCount-1);
// now get random poem
$bydloCod = "&offset=" . $randOffset;
$urlRand = $url . $bydloCod;
$jsonFileRand = file_get_contents($urlRand);
$jfoRand = json_decode($jsonFileRand, true);
$textWallRand = $jfoRand['response'][1]['text'];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment