Search code examples
phpapigoogle-hangouts

Creating a status update from google hangouts through php


So I am trying to figure out if I can create a simple custom PHP script that takes data from a google hangout link and displays back if it is in session.

I am pretty new to Google APi's. My end goal is to create a button on a website that appears whenever someone has joined into a certain designated HANGOUT link.

Do you think this is possible? Any advice would be highly appreciated.

Here was I was thinking:

$stuff = strip_tags(file_get_contents("https://hangouts.google.com/hangouts/_/4im2yhs5kry4vjhlu4yop25tsea"));

$eStrings = explode(' ', $stuff);

I would then retrieve the data from the code and see if it is live or not. If at top of the screen it reads: "You are the only one here" then it is automatically assumed that the session has not begun.

Problem=> You get directed to the google login screen because you need user access.

If anyone has ideas please advise.


Solution

  • While there is a PHP API SDK for Google in beta, it doesn't appear to support Hangouts at all. Google does however expose a client-side JavaScript interface for Hangouts that you should be able to emit and use from your PHP server-side code.

    Using the JS interface, you could use the gapi.hangout.onParticipantsChanged event notification for a given Hangout to know when someone has joined.

    Then leverage the gapi.hangouts.getParticipants() function to pull a list of who's in the hangout and determine if your button should show for the current user.