Phrets is giving Invalid Type error using getobject

332 views Asked by At

can any one help me how to get images of property using reso phrets.

Below is my code which is executing :

$rets   = new \PHRETS\Session($config);
$search = $rets->Search("Property","Residential","*",
    array( 
        'QueryType'           => 'DMQL2',
        "Count"               => 1,
        "Format"              => "COMPACT-DECODED",
        "Limit"               => 5,
        "Offset"              => 0,
        "Select"              => "ListingKeyNumeric,BuyerAgentLastName,buyerAgentFirstName,buyerOfficeName,City,Country,CurrentPrice,StreetName,PostalCode,StateOrProvince,StreetNumberNumeric,BedroomsTotal,BathroomsTotalInteger,LotSizeSquareFeet,YearBuilt,StandardStatus,LotSizeAcres,ListOfficeMlsId,ListPrice,BathroomsFull,BathroomsHalf,PropertySubType,ArchitecturalStyle,MLSAreaMajor,CountyOrParish,Utilities,ParkingTotal,ParkingFeatures,GarageSpaces,View,PoolPrivateYN,PoolFeatures,InteriorFeatures,Appliances,Heating,Cooling,FireplaceYN,FireplaceFeatures,StoriesTotal,ExteriorFeatures,LotSizeDimensions,WindowFeatures,Roof,ConstructionMaterials,FoundationDetails,HighSchoolDistrict,ElementarySchool,MiddleOrJuniorSchool,OriginalEntryTimestamp,DaysOnMarket,Zoning,AssociationFee,AssociationFeeFrequency,ListOfficeName,PricePerSquareFoot,ListAgentFirstName,ListAgentLastName,ListAgentMlsId,InternetAddressDisplayYN,ListingId,PhotosCount",
        "RestrictedIndicator" => "****",
        "StandardNames"       => 1 
    )
);

foreach ($search as $r) {

    $rets_resource = 'Property';
    $object_type   = 'photo';
    $listing_id    = $r['ListingId'];
    $photos        = $rets->GetObject('Property',$classes->first()->getClassName(),'OC17206923,217009806DA,PW17081942','*',0);
    print_r($photos);
}

Result What i am getting :

Illuminate\Support\Collection Object
(    [items:protected] => Array
    (
      [0] => PHRETS\Models\Object Object
      (
       [content_type:protected] => text/xml
       [content_id:protected] => 
       [object_id:protected] => 
       [mime_version:protected] => 1.0
       [location:protected] => 
       [content_description:protected] => 
       [content_sub_description:protected] => 
       [content:protected] => 

       [preferred:protected] => 
       [error:protected] => PHRETS\Models\RETSError Object
      (
        [code:protected] => 20401
        [message:protected] => Invalid Type
      )
    )
  )
)
2

There are 2 answers

0
mike On

What's the value of $classes->first()->getClassName() for the type parameter in the getObject() call?

Maybe you want to use 'photo' or $object_type instead?

0
V-T On

Second param given to the getObject() method is wrong. You are trying to give the class name, instead object type.

Check this phrets getObject() documentation for reference.

Need to change your code like this,

$photos        = $rets->GetObject('Property',$object_type,'OC17206923,217009806DA,PW17081942','*',0);

Also you can change the last param with "1" to get the image url alone. This option may not be supported by all MLSs.