Skip to content

Instantly share code, notes, and snippets.

@caseysoftware
Created April 19, 2013 05:24
Show Gist options
  • Select an option

  • Save caseysoftware/5418319 to your computer and use it in GitHub Desktop.

Select an option

Save caseysoftware/5418319 to your computer and use it in GitHub Desktop.
This is a really rough cut at spidering the Twilio API
<?php
$mapped = array();
spiderAPI('https://XXXX@api.twilio.com/2010-04-01');
function spiderAPI($url) {
global $mapped;
$url = str_replace('XXXX', 'ACxxxx:authToken', $url);
$xml = simplexml_load_file($url);
$mySubUris = $xml->xpath('//SubresourceUris/*');
if ($mySubUris) {
foreach ($mySubUris as $item) {
if(!isset($mapped[$item->getName()])) {
echo $item." -- ";
echo $item->getName()."\n\n";
$mapped[$item->getName()] = $item;
$subUrl = 'https://XXXX@api.twilio.com'.$item;
spiderAPI($subUrl);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment