当前位置: 首页>>代码示例>>PHP>>正文


PHP Rest::get方法代码示例

本文整理汇总了PHP中Rest::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::get方法的具体用法?PHP Rest::get怎么用?PHP Rest::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rest的用法示例。


在下文中一共展示了Rest::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: share

 public static function share($user)
 {
     // Stats
     $stats = array('lists' => array());
     // Lists
     $lists = \Rest::get(static::$endpoints['lists'], array('maxResults' => static::$limit), $user);
     if ($lists && $lists['items']) {
         foreach ($lists['items'] as $list) {
             $stats['lists'][] = array('id' => $list['id'], 'name' => $list['title'], 'picture' => \Render::image('no-photo.png'), 'data' => $list);
         }
     }
     return $stats;
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:13,代码来源:Tasks.php

示例2: share

 public static function share($user)
 {
     // Stats
     $stats = array('contacts' => array());
     $contactsFeed = \Rest::get(static::$endpoints['contacts'], array(), $user);
     if (isset($contactsFeed->entry)) {
         foreach ($contactsFeed->entry as $entry) {
             $contact = array();
             $contact['id'] = @basename($entry->id);
             $contact['name'] = (string) $entry->title;
             $data = $entry->children('http://schemas.google.com/g/2005');
             // Email Address
             if ($data->email) {
                 foreach ($data->email as $entity) {
                     $attributes = (array) $entity->attributes();
                     $newContact['emails'][] = $attributes['@attributes'];
                 }
             }
             // Instant messaging
             if ($data->im) {
                 foreach ($data->im as $entity) {
                     $attributes = (array) $entity->attributes();
                     $contact['im'][] = $attributes['@attributes'];
                 }
             }
             // Phone numbers
             if ($data->phoneNumber) {
                 foreach ($data->phoneNumber as $entity) {
                     $attributes = (array) $entity->attributes();
                     $attributes = $attributes['@attributes'];
                     $attributes['number'] = (string) $entity;
                     $contact['phoneNumbers'][] = $attributes;
                 }
             }
             // Postal addresses
             if ($data->postalAddress) {
                 foreach ($data->postalAddress as $entity) {
                     $attributes = (array) $entity->attributes();
                     $attributes = $attributes['@attributes'];
                     $attributes['address'] = (string) $entity;
                     $contact['postalAddress'][] = $attributes;
                 }
             }
             $stats['contacts'][] = array('id' => $contact['id'], 'name' => $contact['name'], 'picture' => \Render::image('no-photo.jpg'), 'data' => $contact);
         }
     }
     return $stats;
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:48,代码来源:Contacts.php

示例3: backup

 public static function backup($user, $taskId = 0, $syncTaskId = 0)
 {
     // Stats
     $stats = array('links' => 0);
     // Lists
     $lists = \Rest::get(static::$endpoints['links'], array(), $user);
     if ($lists && $lists['items']) {
         foreach ($lists['items'] as $list) {
             // Save List
             $backup = BackupsModel::create();
             $backup->user_id = $user['username']['id'];
             $backup->task_id = $taskId;
             $backup->sync_task_id = $syncTaskId;
             $backup->entity_id = $list['id'];
             $backup->entity_type = static::$kind['link'];
             $backup->entity = json_encode($list);
             $backup->created = date(DATE_TIME);
             $backup->save();
             $stats['links']++;
         }
     }
     return $stats;
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:23,代码来源:Shortner.php

示例4: get

 public function get()
 {
     $res = !empty($this->_params[0]) ? $this->_params[0] : false;
     switch ($res) {
         //List all
         case false:
             break;
             //List only patients
         //List only patients
         case 'patients':
             $this->_filter = array('type' => 'patient');
             break;
             //List only docotrs
         //List only docotrs
         case 'doctors':
             $this->_filter = array('type' => 'doctor');
             break;
             //List gid
         //List gid
         default:
             $this->_filter = array('gid' => $res);
     }
     return json_encode(parent::get());
 }
开发者ID:bshabanov,项目名称:temptasks,代码行数:24,代码来源:resources.php

示例5: backup

 public static function backup($user, $taskId = 0, $syncTaskId = 0)
 {
     // Stats
     $stats = array('blogs' => 0, 'posts' => 0, 'pages' => 0);
     // Channels
     $blogs = \Rest::get(static::$endpoints['blogs'], array('view' => 'ADMIN'), $user);
     if ($blogs && $blogs['items']) {
         foreach ($blogs['items'] as $blog) {
             // Save blog
             $newBlog = BlogsModel::create();
             $newBlog->user_id = $user['username']['id'];
             $newBlog->task_id = $taskId;
             $newBlog->sync_task_id = $syncTaskId;
             $newBlog->kind = static::$kind['blog'];
             $newBlog->blog_id = $blog['id'];
             $newBlog->name = $blog['name'];
             $newBlog->description = $blog['description'];
             $newBlog->url = $blog['url'];
             $newBlog->created_at = date(DATE_TIME, strtotime($blog['published']));
             $newBlog->status = BlogsModel::STATUS_ACTIVE;
             $newBlog->save();
             $stats['blogs']++;
             $newPosts = array();
             do {
                 $payload = array('view' => 'ADMIN');
                 if (isset($posts['nextPageToken'])) {
                     $payload['pageToken'] = $posts['nextPageToken'];
                 }
                 $posts = array();
                 $posts = \Rest::get(sprintf(static::$endpoints['posts'], $blog['id']), $payload, $user);
                 if (isset($posts['result']['error'])) {
                     d($posts);
                 }
                 if ($posts['items']) {
                     foreach ($posts['items'] as $post) {
                         $formatedData = array('user_id' => $user['username']['id'], 'task_id' => $taskId, 'sync_task_id' => $syncTaskId, 'blog_id' => $newBlog->id, 'blogger_blog_id' => $blog['id'], 'kind' => static::$kind['post'], 'post_id' => $post['id'], 'post_status' => $post['status'], 'title' => $post['title'], 'content' => $post['content'], 'created_at' => date(DATE_TIME, strtotime($post['published'])), 'author_id' => $post['author']['id'], 'author_name' => $post['author']['displayName'], 'author_url' => $post['author']['url'], 'author_avatar' => $post['author']['image']['url'], 'status' => PostsModel::STATUS_ACTIVE);
                         $newPosts[] = $formatedData;
                         $stats['posts']++;
                     }
                 }
             } while (isset($posts['nextPageToken']) && $posts['nextPageToken']);
             if ($newPosts) {
                 PostsModel::insertBatch($newPosts);
             }
             // Pages
             $pages = \Rest::get(sprintf(static::$endpoints['pages'], $blog['id']), array('view' => 'ADMIN'), $user);
             if ($pages && $pages['items']) {
                 foreach ($pages['items'] as $page) {
                     $newPage = PagesModel::create();
                     $newPage->user_id = $user['username']['id'];
                     $newPage->task_id = $taskId;
                     $newPage->sync_task_id = $syncTaskId;
                     $newPage->blog_id = $newBlog->id;
                     $newPage->blogger_blog_id = $blog['id'];
                     $newPage->kind = static::$kind['post'];
                     $newPage->page_id = $page['id'];
                     $newPage->page_status = $page['status'];
                     $newPage->title = $page['title'];
                     $newPage->content = $page['content'];
                     $newPage->created_at = strtotime(DATE_TIME, strtotime($page['published']));
                     $newPage->author_id = $page['author']['id'];
                     $newPage->author_name = $page['author']['displayName'];
                     $newPage->author_url = $page['author']['url'];
                     $newPage->author_avatar = $page['author']['image']['url'];
                     $newPage->status = PostsModel::STATUS_ACTIVE;
                     $newPage->save();
                     $stats['pages']++;
                 }
             }
         }
     }
     return $stats;
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:73,代码来源:Blogger.php

示例6: _clean

 public static function _clean($destination, $source, $syncTaskId = 0, $whitelist = array())
 {
     $service = ServicesModel::first(array('library' => 'Calendar'))->toArray();
     $task = TasksServicesModel::first(array('task_id' => $syncTaskId, 'service_id' => $service['id']))->toArray();
     $task['stats'] = json_decode($task['stats'], true);
     // Calendars
     $calendars = CalendarsModel::all(array('user_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId))->toArray();
     // Events
     $toDeleteEvents = array();
     $migratedEvents = MigratedDataModel::all(array('source_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId, 'kind' => static::$kind['event']));
     if ($migratedEvents) {
         $migratedEvents = $migratedEvents->toArray();
         if ($migratedEvents) {
             $destinationCalendars = CalendarsModel::all(array('user_id' => $destination['username']['id'], 'sync_task_id' => $syncTaskId));
             if ($destinationCalendars) {
                 $destinationCalendars = $destinationCalendars->toArray();
                 if ($destinationCalendars) {
                     foreach ($destinationCalendars as $calendar) {
                         // get events
                         $newEvents = array();
                         do {
                             $payload = array('maxResults' => static::$limit);
                             if (isset($events['nextPageToken'])) {
                                 $payload['pageToken'] = $events['nextPageToken'];
                             }
                             $events = \Rest::get(sprintf(static::$endpoints['events'], $calendar['calendar_id']), $payload, $destination);
                             if (isset($events['result']['error'])) {
                                 d(static::$endpoints['events']);
                             }
                             if (isset($events['items'])) {
                                 foreach ($events['items'] as $event) {
                                     if (isset($event['summary'])) {
                                         $newEvents[static::identifier($event, $calendar)] = $event['id'];
                                     }
                                 }
                             }
                         } while (isset($events['nextPageToken']) && $events['nextPageToken']);
                         // Mark events
                         foreach ($migratedEvents as $event) {
                             if (isset($newEvents[$event['unique']])) {
                                 $toDeleteEvents[] = array('eventId' => $newEvents[$event['unique']], 'calendarId' => $calendar['calendar_id']);
                             }
                         }
                     }
                 }
             }
         }
     }
     switch (true) {
         # Share / Clean
         ############################################################################
         case !empty($whitelist):
             // Calendars
             if ($calendars) {
                 foreach ($calendars as $calendar) {
                     if (isset($whitelist['calendars']) && in_array($calendar['calendar_id'], $whitelist['calendars'])) {
                         \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $calendar['calendar_id'], array(), $destination);
                     }
                 }
             }
             break;
             # Move
             ############################################################################
         # Move
         ############################################################################
         case $destination['username']['id'] == $source['username']['id']:
             // Calendars
             if ($calendars) {
                 foreach ($calendars as $calendar) {
                     \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $calendar['calendar_id'], array(), $destination);
                 }
             }
             # Migrate / Sync
             ############################################################################
         # Migrate / Sync
         ############################################################################
         default:
             // Calendars
             if ($calendars && $task['stats']['calendars']) {
                 foreach ($calendars as $calendar) {
                     if ($calendar['calendar_new_id']) {
                         \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $calendar['calendar_new_id'], array(), $destination);
                     }
                 }
             }
             // Events
             if ($toDeleteEvents && $task['stats']['events']) {
                 foreach ($toDeleteEvents as $event) {
                     \Rest::delete('https://www.googleapis.com/calendar/v3/calendars/' . $event['calendarId'] . '/events/' . $event['eventId'], array(), $destination);
                 }
             }
             break;
     }
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:94,代码来源:Calendar.php

示例7: oAuthTokensPermissions

 public static function oAuthTokensPermissions($tokens = false)
 {
     $profile = Rest::get('https://www.googleapis.com/oauth2/v1/userinfo', array('alt' => 'json', 'access_token' => $tokens['access_token']));
     $username = UsersModel::first(array('google_id' => $profile['id'], 'status' => UsersModel::STATUS_ACTIVE)) ?: UsersModel::create();
     if (!static::showWizard()) {
         $redirectUrl = BASE_URL . 'accounts/permissions';
     } else {
         $redirectUrl = BASE_URL . 'accounts/add';
     }
     Util::notice(array('type' => 'success', 'text' => 'You have successfully updated your ' . $username->email . ' account permissions.'));
     $username->last_login = $_SESSION['current']['username']['last_login'];
     $username->save();
     // Credentials update
     $credentials = UsersCredentialsModel::first(array('user_id' => $username->id));
     // Get refresh token
     $data = array('client_id' => OAUTH_CLIENT_ID, 'client_secret' => OAUTH_CLIENT_SECRET, 'redirect_uri' => 'postmessage', 'code' => $tokens['code'], 'grant_type' => 'authorization_code');
     $tokens = Rest::post('https://accounts.google.com/o/oauth2/token', $data);
     $credentials->refresh_token = $tokens['refresh_token'];
     $credentials->access_token = $tokens['access_token'];
     $credentials->expires_at = date(DATE_TIME, time() + $tokens['expires_in']);
     $credentials->save();
     $services = UsersServicesModel::all(array('user_id' => $username->id))->toArray();
     $credentials = $credentials->toArray();
     // User profile
     $userProfile = UsersProfilesModel::first(array('user_id' => $username->id))->toArray();
     $username = $username->toArray();
     $setSession = true;
     // Session thingie
     static::setUsername(compact('username', 'services', 'credentials', 'userProfile', 'setSession'));
     return array('success' => 'true', 'redirectUrl' => $redirectUrl);
 }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:31,代码来源:Auth.php

示例8: _clean

 public static function _clean($destination, $source, $syncTaskId = 0, $whitelist = array())
 {
     $service = ServicesModel::first(array('library' => 'Youtube'))->toArray();
     $task = TasksServicesModel::first(array('task_id' => $syncTaskId, 'service_id' => $service['id']))->toArray();
     $task['stats'] = json_decode($task['stats'], true);
     // Playlists
     $playlists = PlaylistsModel::all(array('user_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId))->toArray();
     // Videos
     $videos = array();
     $migratedVideos = MigratedDataModel::all(array('source_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId, 'kind' => static::$kind['video']));
     if ($migratedVideos) {
         $migratedVideos = $migratedVideos->toArray();
         if ($migratedVideos) {
             $destinationPlaylists = PlaylistsModel::all(array('user_id' => $destination['username']['id'], 'sync_task_id' => $syncTaskId));
             if ($destinationPlaylists) {
                 $destinationPlaylists = $destinationPlaylists->toArray();
                 if ($destinationPlaylists) {
                     foreach ($destinationPlaylists as $playlist) {
                         foreach ($migratedVideos as $video) {
                             $payload = array('part' => static::$part['playlistItems']['minimal'], 'playlistId' => $playlist['youtube_playlist_id'], 'videoId' => $video['identifier']);
                             $vids = array();
                             $vids = \Rest::get(static::$endpoints['playlistItems'], $payload, $destination);
                             if (isset($vids['result']['error'])) {
                                 d($vids);
                             }
                             if ($vids && $vids['items']) {
                                 foreach ($vids['items'] as $vid) {
                                     $videos[] = $vid['id'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Subscriptions
     $newSubscriptions = array();
     $oldSubscriptions = MigratedDataModel::all(array('destination_id' => $destination['username']['id'], 'sync_task_id' => $syncTaskId))->column('identifier');
     do {
         $payload = array('part' => static::$part['subscriptions']['minimal'], 'mine' => 'true', 'maxResults' => static::$limit);
         if (isset($subscriptions['nextPageToken'])) {
             $payload['pageToken'] = $subscriptions['nextPageToken'];
         }
         $subscriptions = \Rest::get(static::$endpoints['subscriptions'], $payload, $destination);
         if (isset($subscriptions['result']['error'])) {
             d($subscriptions);
         }
         if ($subscriptions['items']) {
             foreach ($subscriptions['items'] as $sub) {
                 $newSubscriptions[] = $sub;
             }
         }
     } while (isset($subscriptions['nextPageToken']) && $subscriptions['nextPageToken']);
     switch (true) {
         # Share / Clean
         ############################################################################
         case !empty($whitelist):
             // Playlist
             if ($playlists) {
                 foreach ($playlists as $playlist) {
                     if (isset($whitelist['playlists']) && in_array($playlist['youtube_playlist_id'], $whitelist['playlists'])) {
                         \Rest::delete(static::$endpoints['playlists'], array('id' => $playlist['youtube_playlist_id']), $destination);
                     }
                 }
             }
             // Subscriptions
             if ($newSubscriptions) {
                 foreach ($newSubscriptions as $sub) {
                     if (isset($whitelist['subscriptions']) && in_array($sub['snippet']['resourceId']['channelId'], $whitelist['subscriptions'])) {
                         \Rest::delete(static::$endpoints['subscriptions'], array('id' => $sub['id']), $destination);
                     }
                 }
             }
             break;
             # Move
             ############################################################################
         # Move
         ############################################################################
         case $destination['username']['id'] == $source['username']['id']:
             // Playlist
             if ($playlists) {
                 foreach ($playlists as $playlist) {
                     \Rest::delete(static::$endpoints['playlists'], array('id' => $playlist['youtube_playlist_id']), $destination);
                 }
             }
             // Subscriptions
             if ($newSubscriptions) {
                 foreach ($newSubscriptions as $sub) {
                     \Rest::delete(static::$endpoints['subscriptions'], array('id' => $sub['id']), $destination);
                 }
             }
             break;
             # Migrate / Sync
             ############################################################################
         # Migrate / Sync
         ############################################################################
         default:
             // Playlist
             if ($playlists && $task['stats']['playlists']) {
//.........这里部分代码省略.........
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:101,代码来源:Youtube.php


注:本文中的Rest::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。