Пример #1
0
 /**
  * When the user enters the source location when creating a new gallery.
  *
  * Won't work publically yet, because the user needs to be authenticated to subscribe to push notifications.
  * Also, does not currently work with albums.
  *
  * @return [type] [description]
  */
 private function _vimeography_subscribe_to_trigger($resource, $gallery_id)
 {
     $callback = network_site_url() . '/vimeography/' . $gallery_id . '/refresh/';
     $response = $this->_vimeo->request('/triggers', array('actions' => 'added, removed', 'callback' => $callback, 'resource_uri' => $resource . '/videos'), 'POST');
     echo '<pre>';
     var_dump($response);
     echo '</pre>';
     die;
     switch ($response['status']) {
         case 201:
             //successful
             return TRUE;
             break;
         case 403:
             if ($this->_token === FALSE) {
                 // Trigger unsuccessful, rely on 304 headers.
                 break;
                 // This line will only work when the Vimeo API supports triggers without being authenticated
                 // Though, the user could technically be subscribing to a collection that isn't actually supported in PRO, either.
                 // So be specific in which sources are currently supported.
                 //throw new Vimeography_Exception('Vimeography PRO allows you to show videos from all of your users, channels, albums, & groups.');
             } else {
                 throw new Vimeography_Exception(__("Looks like you don't have the permission to subscribe to this collection.", 'vimeography'));
             }
             break;
         case 405:
         case 500:
             // Unsupported container uri
             throw new Vimeography_Exception(__('The resource that was entered is currently unsupported.', 'vimeography'));
             break;
         default:
             throw new Vimeography_Exception(serialize($response));
             break;
     }
 }