<?php
require_once('app/Mage.php');
Mage::app();
$stores = array_map(function($store) {
return $store->getId();
}, Mage::app()->getStores(true));
foreach ($stores as $store_id) {
// Setup app emulation
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($store_id);
// Load up an emulated category
$cat = Mage::getModel('catalog/category')->load(3);
// Output the URL
echo $cat->getUrl() . PHP_EOL;
// Turn off emulation
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
}