2

I am trying to fetch all MLS agents using phrets, but everything I try returns nothing.

The goal of this is to be able to get more info about a salesperson of an MLS listing.

# Search query
$search = $rets->SearchQuery("roster","Agent","*");

If that is not possible, is there any way how I can figure out all available fields for that class?

Aurelin
  • 753
  • 9
  • 22
  • If you are a vendor/developer, you most likely do not have access to the agents table in your data feed. I'm a vendor for a MLS and we do not have access to that data as it is restricted. – Ricketts Aug 16 '15 at 14:16
  • Hey! I was able to get additional information by looking up each agent of a listing by e-mail address (we do have access to their phone number, website, e-mail address and full name) - see the accepted answer and its comments. – Aurelin Aug 17 '15 at 18:03

2 Answers2

3

You can enter in your RETS login information into RETS M.D. and it will return all metadata and fields for each class (ResidentialProperty, Agent, etc).

If you want to get the listing agent's information for a specific MLS listing and you have the MLS ID, it would be something like this:

    $mlsNumber = 130050044;

    //Perform search query for a specific MLS Id
    $search = $rets->SearchQuery("Property", "9", "(MLNumber_f139={$mlsNumber})", array('Limit' => 1, 'Format' => 'COMPACT'));

    $numRows = $rets->NumRows();

    if ($numRows > 0) {

        $listing = $rets->FetchRow($search);
        // Get Agent's public Id from MLS listing
        $agentId = $listing['ListingPublicID_f1187'];

        // Perform search query for Agent using Agent Id
        $search = $rets->SearchQuery("User", "14", "(AgentPublicID_f1191={$agentId})", array('Limit' => 1, 'Format' => 'COMPACT'));
        $numRows = $rets->NumRows();

        if ($numRows > 0) {
            $listing = $rets->FetchRow($search);
            $agentName = $listing['AgentFullName_f1595'];
            echo "Agent Name : " . $agentName . "<br />";
            // echo more Agent Details here
        }

    }

    $rets->FreeResult($search);

If you wanted to run a search query to return all Agents from a RETS Server, your DMQL might search for all agents with a status of Active.

Andrew Briggs
  • 1,329
  • 12
  • 26
  • I will try that tomorrow, thanks. But what exactly do you mean with "login into RETS M.D."? What is the RETS MD? – Aurelin Oct 29 '13 at 02:28
  • Thank you. I don't really have the agent's public ID, but my listings contain the agent's e-mail address. With that, I can search the agent. RETS MD seems to be a very handy tool! – Aurelin Oct 29 '13 at 15:29
1

To figure out all available fields of a class, use

$fields = $rets->SearchGetFields($search);
V-T
  • 756
  • 2
  • 9
  • 22