EzDevInfo.com

PHRETS

PHP client library for interacting with a RETS server to pull real estate listings, photos and other data made available from an MLS system troydavisson (Troy Davisson) · GitHub troydavisson has 9 repositories written in php, shell, and java. follow their code on github.

Unable to connect RETS server with PHRETS

Can any one tell me what are the mandatory fields to connect using PHRETS?

I used :

$config->setLoginUrl($rets_login_url) ->setUsername($rets_username) ->setPassword(getenv($rets_password)) ->setRetsVersion('1.7.2');


Source: (StackOverflow)

Is there a way to use MLS Api in php

I want to integrate the MLS in my website which is built in php.

Is there any services that could help me out. I want to integrate it in my custom plugin, so that whenever a user searches on my website it pulls the data using MLS api.

I have done some research and found the this link:- http://middleware.idxbroker.com/docs/api/1.0.4/mls.php#searchfields

Can be something that can help me out.

But there is no area where I can get accesskey from, which is required to use the api.


Source: (StackOverflow)

Advertisements

PHrets - Using PHP to create mysql tables from rets - Script

I found this piece of code online which will connect to the rets feed and create mysql tables.

<?php 

/* Raw example on how to use phrets to generate the necessary sql code 
for mysql tables generation from rets. 
Works for me*/ 

require ('phrets0.6.1.php'); 


$rets = new phRETS; 

$Host = 'http://demo.crt.realtors.org:6103/rets/login'; 
$Account = 'Joe'; 
$Password = 'Schmoe'; 
$User_Agent = 'RETS_class/1.0'; 
$Rets_Version = 'RETS/1.5' ; 



$rets->AddHeader("Accept", "*/*"); 
$rets->AddHeader("RETS-Version", "$Rets_Version"); 
$rets->AddHeader("User-Agent", "$User_Agent"); 
$rets->SetParam("cookie_file", "phrets_cookies.txt"); 
//$rets->SetParam("debug_mode", TRUE); // ends up in rets_debug.txt 


$rets->Connect($Host,$Account,$Password); 
        $ResourcesInfo1 = $rets->GetMetadataInfo(); 
        $MetadataInfo1 = $rets->GetMetadataTypes(); 
/*testing4GetTables*/ 
function GetTables($ResourcesInfo, $MetadataInfo) { 
/*        Put toghether all the rets info needed for database tables creation 
in an array. */ 
        foreach ($MetadataInfo as $key => $value){ 
                $Resource = $value['Resource']; 
                foreach ($value['Data'] as $key){ 
                        $tables[$key['Description']] = array( 
                                                                                'ResourceID' => $Resource, 
                                                                                'Description' => $key['Description'], 
                                                                                'ClassName' => $key['ClassName'] , 
                                                                                 'KeyField' => $ResourcesInfo[$Resource]['KeyField'], 
                                                                                'ClassCount' => $ResourcesInfo[$Resource]['ClassCount'] 
                                                                                ); 
                } 

        } 
        return $tables; 
} 

function CreateMysqlTables ($ResourcesInfo, $MetadataInfo, $class){ 
/*function providing the mysql code needed to create mysqltables. 
to be run as the script on the commande line for nicer output*/ 
        $table = GetTables($ResourcesInfo, $MetadataInfo); 

        foreach ($table as $key => $value){ 

                $TablesAndFields[$value['Description']] = $class- 
>GetMetadata($value['ResourceID'],$value['ClassName']); 
        } 

        foreach ($TablesAndFields as $key => $value){ 
                $find = array ('/ /', '/-/'); 
                $TableName = preg_replace($find, "_", $key); 
                echo "\n\r CREATE TABLE IF NOT EXISTS $TableName  (\n\r"; 
                 foreach ( $value as $key2 => $value2){ 
                                 echo "`$value2[SystemName]` "; 
                                 ConvertTypeToMysql($value2[DataType], $value2[MaximumLength]); 
                 } 
                 echo "`MyNewTablesTimeStamp` timestamp NOT NULL default 
CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\r"; 
        echo " PRIMARY KEY (".$table[$key]['KeyField']."));\n\r"; 
        } 
} 

function ConvertTypeToMysql($datatype, $datalenght){ 
/*        This function  to convert mls datatype and datalenght to mysql. 
        Change to fit your needs works for me: db2 to mysql (flexmls)*/ 
        switch ($datatype){ 
        case "Character": 
                if ($datalenght >= 255){ 
                        echo "text  collate utf8_unicode_ci default NULL, \n\r"; 

                } 
                elseif (!$datalenght){ 
                        echo "$datatype(25) collate utf8_unicode_ci default NULL, \n\r"; 

                } 
                else { 
                        echo "$datatype($datalenght) collate utf8_unicode_ci default NULL, 
\n\r"; 

                } 

                break; 

        case "Decimal": 

                echo "$datatype($datalenght,0) default NULL, \n\r"; 
                break; 

        case "Int": 

                echo "$datatype($datalenght) default NULL, \n\r"; 
                break; 

        case "Long": 
/*                note:if I put this case after case ("Date" or "Boolean"): it won't 
work, Why? is Long a Boolean?'*/ 
                echo "LONGTEXT collate utf8_unicode_ci default NULL, \n\r"; 
                break; 

        case ("Date" or "Boolean"): 

                echo "$datatype default NULL, \n\r"; 
                break; 


        } 

} 
CreateMysqlTables ($ResourcesInfo1, $MetadataInfo1, $rets); 

$rets->Disconnect(); 

?> 

Sorry for the long piece of code.

I have established a connection to my Wordpress site through FTP using my IDE and have the PHrets files loaded on there.

My final goal is to populate mysql database with all of the listings in the rets feed and then have my website work off of that while the database is updated every so often checking for updated or new listings.

If anyone could point me in the right direction I would greatly appreciate it.


Source: (StackOverflow)

php phrets: Automatically update the listing photos onto my server?

When using php phrets to pull listing photos from the MLS, does it automatically update the old listing photos with the new ones onto my web server once the MLS update theirs?

Below is my code for pulling listing photos?

<?php  
    $search = $rets->SearchQuery(
        'Property',                             
        6,                                      
        '(105=2014-01-01+),(193=A)',    
        array(
            'Format'    => 'COMPACT-DECODED',
            'Select'    => '',
            'Count'     => 1
        )
    );

    if($rets->TotalRecordsFound() > 0) {

        while($data = $rets->FetchRow($search)) {

            $id = $data['sysid'];
            $n = 1;
            $photos = $rets->GetObject('Property', 'Photo', $id);
            foreach($photos as $photo) {
                if ($photo['Success'] == true) {
                    file_put_contents('images/'.$id.'-'.$n.'.jpg', $photo['Data']);
                }
                $n++;
            }
            $rets->FreeResult($photos);
        }
        echo "Collected data successfully\n";
    } else {
        echo '0 Records Found';
    }
?>

Source: (StackOverflow)

Including PHRETS into a Symfony2 project

How can I include this library: https://github.com/troydavisson/PHRETS into a symfony project?

This is my composer.json:

{
    "name": "marysalcedo/reactive-pandora",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-0": {
            "": "src/",
            "SymfonyStandard": "app/"
        },
        "files": []
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.6.*",
        "doctrine/orm": "~2.2,>=2.2.3,<2.5",
        "doctrine/dbal": "<2.5",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~3.0,>=3.0.12",
        "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "doctrine/mongodb-odm": "1.0.*@dev",
        "doctrine/mongodb-odm-bundle": "3.0.*@dev",
        "maciejczyzewski/bottomline": "*",
        "doctrine/doctrine-fixtures-bundle": "2.2.*",
        "troydavisson/phrets": "2.*"
    },
    "minimum-stability": "dev",
    "require-dev": {
        "sensio/generator-bundle": "~2.3"
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }
    }
}

Whenever I try to use the object \PHRETS\Configuration I get an error:

new \PHRETS\Configuration();

This is the error I get back:

[Symfony\Component\Debug\Exception\ClassNotFoundException]                   
  Attempted to load class "Configuration" from namespace "PHRETS".             
  Did you forget a "use" statement for e.g. 

Why isn't it being included?


Source: (StackOverflow)