Spiga

How to check if a yahoo user exits using php

June 22, 08 by Gabi Solomon

On a recent project i had to find a way to test if a yahoo user account entered by the user is real or not. The purpose of this was to not create unnecessary load on the server for an id that wasn't real. So i went to the yahoo registration form and looked on how do they check it.

In that form the access this address if i test my id :

https://edit.yahoo.com/reg_json?PartnerName=yahoo_default&AccountID=solomongaby@yahoo.com&ApiName=ValidateFields

There were a few other get parameters but i strip them out, since they didnt seem to add any more value, and the result was the same. If the account you entered ( solomongaby@yahoo.com in this case ) is a valid one the result will be :

HTML:
  1. {
  2.   "ResultCode":"PERMANENT_FAILURE",
  3.   "SuggestedIDList": ["infostud_ro79@yahoo.com",  "infostud_ro12@yahoo.com",  "infostud_ro89@yahoo.com"], 
  4.    "SuggestedDBIDList":["infostud_ro33@rocketmail.com","infostud_ro38@ymail.com"],
  5.    "ErrorList":[{"ErrorCode":"100000","ErrorField":"AccountID"}]
  6. }

As you see the result already has the recomandation into it. If you try to run the same request for an id that doenst exist like solomongaby12382109 you would get this result:

HTML:
  1. {"ResultCode":"SUCCESS"}

Based on this i wrote a small php function :

PHP:
  1. $check = file_get_contents('https://edit.yahoo.com/reg_json?PartnerName=yahoo_default&AccountID='.$this->id_name.'@yahoo.com&ApiName=ValidateFields');
  2.         if ( strpos($check,'SUCCESS')===false ) return true;
  3.         else return false;

Hope this has helped you.
Cheers