本文整理汇总了PHP中Meta::campImport方法的典型用法代码示例。如果您正苦于以下问题:PHP Meta::campImport方法的具体用法?PHP Meta::campImport怎么用?PHP Meta::campImport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Meta
的用法示例。
在下文中一共展示了Meta::campImport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _import
protected function _import($org, $advertisers, &$view)
{
if (!isset($org->meta['model']) || !isset($org->meta['rate'])) {
return $view->set('message', 'Please update <a href="/admin/settings">Commission Settings</a>');
}
$a = array_values($advertisers)[0];
$advert_id = RM::post('advert_id', $a->getMongoID());
$advert = \User::first(['_id = ?' => $advert_id, 'type = ?' => 'advertiser']);
if (!$advert) {
return $view->set('message', 'Invalid Request!!');
}
if (!isset($advert->meta['campaign'])) {
return $view->set('message', 'Please Update Advertiser campaign settings!!');
}
$csv = $_FILES['csv'];
$tmp = $csv['tmp_name'];
if ($csv['type'] !== 'text/csv') {
return $view->set('message', 'Invalid CSV file!!');
}
$file = APP_PATH . '/uploads/' . uniqid() . '.csv';
if ($csv['error'] > 0 || !move_uploaded_file($tmp, $file)) {
return $view->set('message', 'Error uploading csv file!!');
}
$fp = fopen($file, 'r');
$urls = [];
while (($line = fgetcsv($fp)) !== false) {
$link = $line[0];
if (!$link) {
continue;
}
$urls[] = $link;
}
fclose($fp);
unlink($file);
\Meta::campImport($this->user->_id, $advert_id, $urls);
$view->set('message', 'Campaigns Imported we will process them within an hour!!');
}
示例2: _rssFeed
/**
* Process the RSS Feed Urls from Platforms Table and queue the AD
* urls in the Meta Table for campaign importing
*/
protected function _rssFeed()
{
// find all the platforms for the advertisers
$orgs = \Organization::all([], ['_id']);
foreach ($orgs as $o) {
$platforms = \Platform::rssFeeds($o);
// get feed for each platform
foreach ($platforms as $p) {
$meta = $p->meta;
$rss = $meta['rss'];
// parsing is stopped
if (!$rss['parsing']) {
continue;
}
$lastCrawled = null;
if (isset($rss['lastCrawled'])) {
$lastCrawled = $rss['lastCrawled'];
}
$result = \Shared\Rss::getFeed($rss['url'], $lastCrawled);
$urls = $result['urls'];
$rss['lastCrawled'] = $result['lastCrawled'];
$meta['rss'] = $rss;
$p->meta = $meta;
$p->save();
// save the lastCrawled time
$user = \User::first(['org_id' => $o->_id, 'type' => 'admin'], ['_id']);
\Meta::campImport($user->_id, $p->user_id, $result['urls'], $rss['campaign']);
}
}
}