本文整理匯總了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);