以编程方式评估域是否包含Google Apps(Programmatically assessing if a domain has Google Apps or not)

编程入门 行业动态 更新时间:2024-10-28 14:34:35
以编程方式评估域是否包含Google Apps(Programmatically assessing if a domain has Google Apps or not)

我过去通过向“ http://www.google.com/a/ {domain} / ”执行CURL请求并检查此字符串来评估某个域是否包含Google Apps“[在此处登录控制面板]“,如果它有,它有Google Apps,如果没有,他们没有Google Apps。

但最近谷歌转而使用通用的http://admin.google.com登录页面,并没有对域名进行区分。 现在,这显然打破了我以前检查它是否有Google Apps的方式。

有没有人有任何其他解决方法来做到这一点?

我尝试了一些来自Google API的网址,但是他们需要Auth ...

注意:我不想通过MX / TXT记录进行检查,我需要检查他们是否有Google Apps,而不是他们是否使用过Google Apps。 这样做的原因是我开发了一个Google Apps Toolkit ,它进行了一系列检查,并给出了域的状态,我用来测试域名是否具有100%准确性的域名的旧方法,以及其他所有在线Google Apps测试人员我使用它是相当不准确的,因为他们检查MX记录。 我不想陷入这个陷阱。 这对曾经拥有Google Apps但又转移到其他提供商并希望转回经销商的域名非常有帮助(这种情况比您想象的更频繁,我为经销商工作)

I used to assess whether or not a domain had Google Apps or not by doing a CURL request to "http://www.google.com/a/{domain}/" and checking for this string "[sign in here for the control panel]", if it had it, it had Google Apps, if it didn't than they didn't have Google Apps.

But recently Google switched to the universal http://admin.google.com login page, and it made no distinction between domains. Now this obviously breaks how I used to check to see if it had Google Apps.

Does anyone have any other work-arounds to do this?

I tried a few URL's from Google API's, but they require Auth...

NOTE: I do not wish to check via MX/TXT records, I need to check if they have Google Apps, not if they are using it. The reason for this is I had developed a Google Apps Toolkit that did a series of checks and gave the status of a domain, the old method I used to test if a domain had Google Apps was 100% accurate, every other online Google Apps tester I used was fairly inaccurate due to them checking MX records. I don't want to fall into this trap. This was very helpful for domains that used to have Google Apps but moved to another provider and want to move back to a reseller (It happens more often than you would think, I work for a reseller)

最满意答案

我成功地弄明白了!

要确定某个域是否已在其上购买Google Apps,请执行以下操作:

执行CURL请求:“ https://www.google.com/a/ {domain} / ServiceLogin”

搜索以下字符串:“ 抱歉,您已到达未使用的域的登录页面 ”,如果它包含该字符串,则它没有 Google Apps,如果它没有该字符串而不是包含Google Apps。

一个示例PHP函数(我在这个例子中使用的是file_get_contents而不是CURL,因为它更短,请注意你需要在php.ini中启用基于URL的位置)

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; }

示例: https : //gapps.qk.com.au/?domain = when.io

即使域是经销商并使用自定义SSO解决方案,也可以继续使用此方法。

I have successfully figured it out!

To determine if a domain has Google Apps purchased on it, just do the following:

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

Search for the following string: "Sorry, you've reached a login page for a domain that isn't using", if it contains that string, it does not have Google Apps, if it doesn't have that string than it does contain Google Apps.

An example PHP function (I'm using file_get_contents instead of CURL on this example because it is shorter, please note you will need to enable URL based locations 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 using a custom SSO solution it should continue to work.

更多推荐

本文发布于:2023-07-30 02:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321646.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   Google   Apps   domain   assessing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!