We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43957
    • 79 Posts
    I'm thinking I'll use this post to document my voyage of discovery and glady recieve any company/advice along the way.

    I have little experience with coding in PHP, but have managed to create some great sites with ModX and the fantastic packages available, eg. NewsPublisher, (Many thanks Bob), being one I hope to use as a key player in this development.

    I thought I would throw my questions out there in the hope that someone else is trying/has tried/has implemented Google API within a modx site.

    Here's what I'm hoping to achieve:

    I'd like to be able to integrate Google Drive into my Modx site, so that my users can browse GoogleDocs from the front end and select a document which then displays and embedded version in the page.

    I've harnessed the power of Newspublisher and I've acheived a basic version of this with a link Template Variable which I populate with the "share" option in googledocs, which successfully displays an embedded version of the document in the page.

    But I would like to integrate the process of browsing and selecting documents into the front end... and much more than this too (Enabling searching of content within googledocs from front end/editable Google Calendar etc). My biggest challenge yet!!!!

    I've found some info on using Google Drive as a Media Source (which looks promising):
    https://forums.modx.com/thread/78397/google-drive-on-mediasources

    I've trawled google's developer site and found this:
    https://developers.google.com/drive/examples/php#putting_together_the_pieces_getting_a_complete_set_of_credentials_for_every_request

    Which appears to be a great guide to achieving what I want.

    I've also found HybridAuth:
    http://rtfm.modx.com/extras/revo/hybridauth

    Which appears to acheive the Google Authorization process.

    Like I say, I'm pretty new/lame when it comes to coding PHP, so feel free to say "Hey Buddy, you're way in over your head here, you need to pay someone else to do this for you" or "Yeah, we can help with a gentle nudge in the right direction, you can fulfil your dreams!"

    So I wonder,


    1. Does HybridAuth actually achieve all the authorization I need set the ball rolling?
    2. Even sillier question - Do I need to install/locate the Google API libraries in my ModX site to achieve the above, anyone else tried something similar?
    3. Should I consider other options such as developing with Eclipse+PHP to get off the ground before I even venture into this playground?
    4. Question to self - Am I asking the right questions in the right way? So many questions......

    I'll continue to update my post with additional information as I make more discoveries, which I hope will end in a solution for me that may also help others. So, if anyone wants to join the ride and can provide any "gentle nudges" It would be very much appricatated. Hopefully one day I'll be able to contribute to the answers more one day, than to be asking all the questions.
      • 36924 ☆ A M B ☆
      • 298 Posts
      Interesting scenario it will be. Something I thought of few days ago. Will listen for what the pros can help us with.
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        As far as #3 goes, after trying out Eclipse+PHP from time to time I finally caught PhpStorm at a time when it was on one of its periodic half-price sales, and am very glad that I did. I do have to say, though, that I still haven't buckled down and learned how to use it properly.

        This should be helpful in dealing with OAuth https://developers.google.com/drive/training/drive-apps/auth/credentials (use the PHP tab to get the sample PHP code)

        A few tutorials
        http://code.google.com/p/oauth-php/wiki/ConsumerHowTo
          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
          • 43957
          • 79 Posts
          I've done a little more research.

          I've not had much joy finding the HybridAuth package, so not been able to try that out. Also, gdriver (Google Drive Media Source) package fails to install.

          Like I say I've not really dabbled in PHP so I'm bumbling along. I found this Google example - Quickstart: Run a Drive App in PHP: https://developers.google.com/drive/quickstart-php

          I created a project in Google API to get the keys

          I copied the google_client api to my site into a folder and copied the code into a snippet and called it on a page... which does get me to the login and authorization page and provides me with my code to paste into my application.

          However, there's no place to paste it in as I relize I'm calling the PHP code from within an HTML page and the example says:

          "When you run the sample from command-line, it provides a link you'll need to visit in order to authorize."


          Am I heading along the right path to use snippets to implement the authorization?

          I'm going off to look at other authorization stuff:
          https://developers.google.com/drive/about-auth
          http://code.google.com/p/google-api-php-client/

          [ed. note: dave-b last edited this post 13 years, 1 month ago.]
            • 43957
            • 79 Posts
              • 43957
              • 79 Posts
              Well, I've found a way to do partly what I wanted to achieve.

              Google Picker https://developers.google.com/picker/docs/ allows you to browse your Google Drive files and you can configure the folder views etc.

              I've used the basic example so far to allow me to set the URL of a google doc to a text TV in Newspublisher. The output is rendered in an iframe which displays a preview of the document in my web page. Nice!

              It does require that you're logged into your google account for the browser session otherwise the documents don't display, so not a fully integrated solution, but works quite nicely.

              I'm still going to continue my voyage and report any more findings.