We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6531
    • 154 Posts
    Yeah, without a doubt the best part is that the client can manage the videos through vimeo -- now they don’t call me every other day asking to add more videos to the site!
    (Although if you’re billing by the hour .... hmm ... wink

    As soon as I gather my notes I’ll put up the new code ... thanks for your kind words
      • 23299
      • 1,161 Posts
      Indeed. The Vimeo interface is pretty clean. The best part with the Albums is the user can drag and drop videos to customize the presentation order or choose one of seven arrangement options.
        • 3061
        • 2 Posts
        Thanks Danzg great snippet. I have now hit the 20 limit on my Vimeo videos however...so any news on your updated snippet?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I’m using a desktop app for Mac or Windows that generates an HTML file with all the javascript includes and what-have-you for a video light box presentations. I specify a filename to reflect the alias of the page that will be displaying the video gallery, load the resulting directory into my assets/media directory, and use a snippet to grab the contents of the generated .html file and process it. Voila, instant video gallery with lightbox.

          http://videolightbox.com/

          My processing snippet
          <?php
          // load up the css and js files
          $modx->regClientCSS('assets/media/engine/css/videolightbox.css');
          $modx->regClientCSS('<style type="text/css">#videogallery a#videolb{display:none}</style>');
          $modx->regClientCSS('assets/media/engine/css/overlay-minimal.css');
          $modx->regClientStartupScript('assets/media/engine/js/jquery.tools.min.js');
          $modx->regClientStartupScript('assets/media/engine/js/swfobject.js');
          $modx->regClientStartupScript('assets/media/engine/js/videolightbox.js');
          // read and parse the generated file
          $filename = $modx->documentObject['alias'];
          $file = file_get_contents("assets/media/$filename.html");
          $gallery = explode('BODY', $file);
          $div = $gallery[1];
          $div = ltrim($div, 'section -->');
          $div = rtrim($div, '<!-- End VideoLightBox.com');
          $div = str_replace('src="data', 'src="assets/media/data', $div);
          return $div;
          ?>
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 23299
            • 1,161 Posts
            Interesting Susan.

            I will download this app and take it for a spin.

            As far as I can tell it skins different templates around videos that have been transcribed and hosted on other sites? It then generates the imbed function to add to your own site. It seems cool, but it adds extra steps to what is being discussed on this thread. Of course this offers more flexibility as this thread is all about using Vimeo for the transcribing and host duties.

            This whole video thing is still a process: shoot video, transcribe video to editing codec, edit video, transcribe for home use (max quality), transcribe for web use (set size, quality, codec), upload to video host (Vimeo, Youtube, etc will also perform their own transcribe function). We then come to cool ways of presenting a single or a bunch of videos on our own sites using MODx goodness. Of course some of these steps are minimized when using video from cell phones and more basic workflow etc. (I am one of the main moderators at Cinema5d.com and we go over all this stuff all the time.)

            Still, its great to see more delivery options and snippets being created to make video work with MODx...
              • 23299
              • 1,161 Posts
              This is just a questioning shout-out to Danzg to see if he has spent any more time refining this Vimeo imbed snippet?
                • 6531
                • 154 Posts
                Sorry about the delay ... hope this helps...

                OVERVIEW
                In order to make use of the Vimeo Advanced API from our own website, we need four OAuth Tokens:
                (1) a CONSUMER KEY; (2) a CONSUMER SECRET; (3) an OAUTH ACCESS TOKEN; and (4) an OAUTH ACCESS TOKEN SECRET.

                We're going to:
                (A) Install the Vimeo API on our modx site.
                (B) Register our site with Vimeo and get our Consumer Keys.
                (C) Authorize our site and get our OAuth Tokens.
                (D) Start using the Advanced API for our Vimeo Gallery!


                PART A - INSTALL THE VIMEO API LIBRARY ON YOUR SITE

                1. Download the "Advanced API PHP Library" from this page: http://www.vimeo.com/api/docs/downloads
                2. From that zip, upload "[tt]vimeo.php[/tt]" and "[tt]index.php[/tt]" to a folder called "[tt]vimeo[/tt]" on the root of your website (i.e., so it's in the same folder as your [tt]"assets"[/tt] and [tt]"manager"[/tt] folders.)
                3. Create a folder within "[tt]vimeo[/tt]" called "cache" with permissions 777.
                4. You need the full absolute server path to [tt]vimeo.php[/tt]. For example, on DreamHost, my absolute path would be [tt]/home/danzg/mycoolsite.com/vimeo/vimeo.php[/tt].

                PART B - REGISTER YOUR SITE AS AN API APPLICATION ON VIMEO

                5. Login to your vimeo account, and register your website as a new "app" at http://www.vimeo.com/api/applications/new
                6. Use the URL of your website as the "Application URL".
                7. IMPORTANT: Enter the URL to the [tt]index.php[/tt] you just uploaded as the "Application Callback URL".
                   (In my example, this would be "[tt]http://mycoolsite.com/vimeo/index.php[/tt]")
                   If it's your first time registering an app, you MAY have to wait for a human to authorize the request.
                8. Get your Consumer Key and Consumer Secret and SAVE THESE TWO CODES. YOU WILL NEED THEM.

                PART C - AUTHORIZE YOUR SITE

                Now you need to do a 1-time authorization of your site.
                9. Edit line 6 of [tt]vimeo/index.php[/tt] (on your site) and put in the values you just obtained.
                $vimeo = new phpVimeo('CONSUMER_KEY', 'CONSUMER_SECRET');

                   should become something like:
                $vimeo = new phpVimeo('3bab4a234d4c0e345df678ac669548ca', 'a9a44ed654e123a');
                


                10. Around line 60 of [tt]vimeo/index.php[/tt], there is a comment "[tt]// Set the token[/tt]". The next line is:
                $vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);

                   insert these lines right after it:
                echo "
                ";
                echo "Your oauth access token: ";
                echo $_SESSION['oauth_access_token'];
                echo "
                ";           
                echo "Your oath access token secret: ";
                echo $_SESSION['oauth_access_token_secret'];
                echo "
                ";
                


                11. Go to your browser and open up your [tt]vimeo/index.php[/tt] page, e.g., I would go to [tt]http://mycoolsite.com/vimeo/index.php[/tt]
                   At the bottom it will say:
                   "Click the link to go to Vimeo to authorize your account."
                   Go ahead and click that long nasty link (which should contain an OAuth token).

                12. This will take you to Vimeo, where you may need to sign in.
                   You should see:
                   "Do you want to authorize this app? ... Yes, authorize ...  "

                   Go ahead and authorize, and, if you entered your callback URL correctly, it should take you back to your index.php, where, at the top, you will see
                   [tt]Your oauth access token: xxxxxxxxxxxxx
                   Your oath access token secret: xxxxxxxxxxxxxxxxx
                   [/tt]
                   SAVE THESE TWO CODES. YOU WILL NEED THEM.

                Congratulations!

                You have now authorized your website for full access to your vimeo account, and you can now use all the cool methods in the API, which you can peruse here:
                http://vimeo.com/api/docs/methods

                13. DO NOT LOAD THE [tt]vimeo/index.php[/tt] PAGE AGAIN, or I believe you will end up re-setting your tokens. Might want to just delete it. You should only have to do the above steps once.

                14. DO NOT DELETE THE [tt]vimeo/vimeo.php[/tt] FILE -- that is needed by any PHP code / snippets that call the Vimeo API.


                Now, any time you want to call the Advanced API, your PHP will start with these 3 lines:

                require_once('/absolute/path/to/vimeo.php');
                $vimeo = new phpVimeo('YourConsumerKey', 'YourConsumerSecret');
                $vimeo->setToken('YourOAuthAccessToken','YourOAuthAccessTokenSecret');
                



                Finally, here is the revised snippet which is not limited to 20 videos, and should get you started taking advantage of the Advanced API.As before, call it with the album ID for which you want a gallery (see my previous post for info on obtaining album IDs)

                <?php
                require_once('/absolute/path/to/vimeo.php');
                $vimeo = new phpVimeo('YourConsumerKey', 'YourConsumerSecret');
                $vimeo->setToken('YourOAuthAccessToken','YourOAuthAccessTokenSecret');
                
                $output = '<div class="albumGallery">';
                $result = $vimeo->call('vimeo.albums.getVideos', array('album_id' => $albumID,full_response => '1'));
                $videos = $result->videos->video;
                foreach ($videos as $video) {
                   $output .= ' <a href="'.$video->urls->url[0]->_content.'" title="'.$video->title.'" rel="zoombox[group]">';
                   $output .= '  <div class="albumGalleryItem">';
                   $output .= '   <div class="ImgContainer"><img src="'.$video->thumbnails->thumbnail[1]->_content.'"></div>';
                   $output .= '   <div class="albumGalleryCaption">'.$video->title.'</div>';
                   $output .= '   <div class="albumGalleryDescription">'.nl2br($video->description).'</div>';
                   $output .= '  </div>';
                   $output .= ' </a>';
                }
                
                $output .= '</div>';
                
                return $output;
                
                [ed. note: danzg last edited this post 14 years, 10 months ago.]
                  • 23299
                  • 1,161 Posts
                  Wow!

                  Thanks! Now is not a good time, but I can’t wait to take this for a spin. This whole MODx Vimeo snippet and procedure is very cool...
                    • 23299
                    • 1,161 Posts
                    Anyone get this to work?

                    After many weeks I am trying this new version and can’t even get the token to register?

                    The previous version of these Vimeo snippets have also stopped working? New upgrade with Vimeo clashing with the php code in these snippets?
                      • 3061
                      • 2 Posts
                      I have authorised my website as an app ok and have the oauth stuff fine, but when I run the snippet I keep getting this error:

                      Parse error: syntax error, unexpected ':' in /home/benmould/public_html/benmoulden.co.uk/core/cache/includes/elements/modsnippet/2.include.cache.php on line 7

                      As anyone got this to work?