本文整理汇总了PHP中Browser::openUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Browser::openUrl方法的具体用法?PHP Browser::openUrl怎么用?PHP Browser::openUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Browser
的用法示例。
在下文中一共展示了Browser::openUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_save
public function action_save()
{
$msg = '';
$user_id = $this->request->post('user_id');
$b = new Browser();
$url = "https://api.vk.com/method/users.get?user_ids=" . $user_id;
$response = $b->openUrl($url)->jsonAsArray();
if (isset($response['response'])) {
foreach ($response['response'] as $user) {
$userRecord = ORM::factory('User')->where('user_id', '=', $user['uid'])->find_all();
if (count($userRecord)) {
$msg = 'Пользователь уже добавлен';
$this->template->content = View::factory('msg/error')->bind('msg', $msg);
} else {
$newUser = ORM::factory('User');
$newUser->user_id = $user['uid'];
$newUser->first_name = $user['first_name'];
$newUser->last_name = $user['last_name'];
if ($newUser->save()) {
$msg = "Добавлен";
$this->template->content = View::factory('msg/success')->bind('msg', $msg);
}
}
}
}
}
示例2: users
// class and creates the table if it doesn't already exist.
// Wouldn't normally be needed if the table is already there.
$db = ORM::get_db();
$db->exec("\n CREATE TABLE IF NOT EXISTS users (\n id INTEGER PRIMARY KEY AUTO_INCREMENT, \n user_id TEXT,\n first_name TEXT,\n last_name TEXT\n ) DEFAULT CHARSET=utf8;");
$db->exec("\n\t\tCREATE TABLE IF NOT EXISTS trackers (\n \t\tid INTEGER PRIMARY KEY AUTO_INCREMENT, \n \t\tuser_id TEXT,\n\t\t\tdate TEXT,\n\t\t\tparams TEXT\n\t\t) DEFAULT CHARSET=utf8;");
$users = ORM::for_table('users')->find_many();
$idList = array();
foreach ($users as $user) {
$idList[] = $user->user_id;
}
$idList = implode(',', $idList);
$b = new Browser();
// $url = "https://api.vk.com/method/users.get?user_ids=101009040,parruslt&fields=online,online_mobile";
$url = sprintf("https://api.vk.com/method/users.get?user_ids=%s&fields=online,online_mobile", $idList);
// $url = "https://api.vk.com/method/users.get?user_ids=138355715&fields=online,online_mobile";
$response = $b->openUrl($url)->jsonAsArray();
// echo "<pre>";
// print_r($response);
// echo "</pre>";
// exit();
if (isset($response['response'])) {
foreach ($response['response'] as $user) {
$userRecord = ORM::for_table('users')->where('user_id', $user['uid'])->find_one();
if ($userRecord) {
if (isset($user['online']) && $user['online'] == '1') {
$currentDate = date('Y.m.d');
$trackRecord = ORM::for_table('trackers')->where(array('user_id' => $user['uid'], 'date' => $currentDate))->find_one();
if ($trackRecord) {
$params = unserialize($trackRecord->params);
$params[] = array('time' => date('H:i'), 'from_mobile' => isset($user['online_mobile']) ? 1 : 0, 'from_mobile_app' => isset($user['online_app']) ? 1 : 0);
$trackRecord->params = serialize($params);