Programmatically evaluate whether a domain has Google Apps or not.

I used to evaluate whether or not Google Apps had a domain by running a CURL request at " http://www.google.com/a/ {domain} / " and checking this line "[come here for control panel]" if it she had, she had Google Apps, if she wasn’t, than Google Apps.

But Google recently moved to the generic page http://admin.google.com , and it made no distinction between domains. Now this obviously breaks down, as I'm used to checking if Google Apps has it.

Does anyone have any other actions?

I tried several URLs from the Google API, but they require Auth ...

NOTE. I don’t want to check MX / TXT records, I need to check if they have Google Apps, and not if they use it. The reason for this is because I developed the Google Apps Toolkit , which did a series of checks and gave the domain status, the old method I used to check if Google Apps was 100% accurate, every other Google Apps online tester was pretty inaccurate due to verification of MX records. I do not want to fall into this trap. This was very useful for domains that previously used Google Apps, but moved to a different provider and want to return to the reseller (this happens more often than you think, I work for the reseller)

+4
source share
2 answers

I successfully figured it out!

To determine if you purchased a Google Apps domain on it, follow these steps:

Make a CURL request: " https://www.google.com/a/ {domain} / ServiceLogin"

Look for the following line: " Unfortunately, you have reached the login page for a domain that does not use ", if it contains this line, it does not have Google Apps, if it does not have this line, except for Google Apps.

PHP function example (I use file_get_contents instead of CURL in this example because it is shorter, note that you will need to allow allocation based on the URL in php.ini)

function lookupGoogleAccount($domain) { $url = "https://www.google.com/a/$domain/ServiceLogin"; $extpage = file_get_contents($url); $not_gapps = strpos($extpage,"Sorry, you've reached a login page for a domain that isn't using"); return !$not_gapps; } 

Example: https://gapps.qk.com.au/?domain=never.io

Using this method, even if the domain is a reseller and uses a custom SSO solution, it should continue to work.

+10
source

The answer from Mattisdada is not 100% reliable.

There may be times when this domain has been activated and verified, so it can be reached through " https://www.google.com/a/ {domain} / ServiceLogin", as suggested, but this does not mean that actually in fact, he uses Google applications.

The best solution I could find was to check the MX records that google is looking for. Since this is a php question, the best option is to use the getmxrr function.

-one
source

Source: https://habr.com/ru/post/1492879/


All Articles