本文整理汇总了PHP中Position::setDeviceKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Position::setDeviceKey方法的具体用法?PHP Position::setDeviceKey怎么用?PHP Position::setDeviceKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::setDeviceKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$web = new sfWebBrowser();
$latest = Doctrine::getTable('Position')->createQuery('p')->limit(1)->orderBy('p.timestamp DESC')->fetchOne();
$this->logSection($this->namespace, 'Getting latest instamapper positions');
$instamapper = $web->get('http://www.instamapper.com/api?action=getPositions&key=' . sfConfig::get('app_instamapper_api_key') . '&num=1000' . ($latest instanceof Position ? '&from_ts=' . $latest->getTimestamp() : '') . '&format=json');
try {
if (!$instamapper->responseIsError()) {
$json = json_decode($instamapper->getResponseText());
foreach ($json->positions as $gps) {
if (!$latest instanceof Position || $gps->timestamp >= $latest->getTimestamp()) {
$position = new Position();
$position->setDeviceKey($gps->device_key);
$position->setDeviceLabel($gps->device_label);
$position->setTimestamp($gps->timestamp);
$position->setLatitude($gps->latitude);
$position->setLongitude($gps->longitude);
$position->setAltitude($gps->altitude);
$position->setSpeed($gps->speed);
$position->setHeading($gps->heading);
$position->save();
echo '.';
$this->new++;
}
}
} else {
// Error response (eg. 404, 500, etc)
}
} catch (Exception $e) {
// Adapter error (eg. Host not found)
}
echo "\n";
$this->logSection($this->namespace, 'Done: ' . $this->new . ' added.');
}