lukeoliff / zpg-rtf-php
此软件包已被废弃且不再维护。未建议替代软件包。
ZPG实时数据包集成软件包
v0.1.3
2020-04-17 14:36 UTC
Requires
- php: ~7
- guzzlehttp/guzzle: ^6
- league/json-guard: ^1.0
- league/json-reference: ^1.0
Requires (Dev)
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2020-05-01 18:49:50 UTC
README
我不再有访问此API以继续SDK工作的权限。我很乐意将项目转交给其他人。在此期间,项目将被存档。请通过twitter.com/lukeocodes与我联系讨论。
PHP版本的ZPG实时列表服务
待办事项(按优先级排序)
- 检查枚举值在
set中的值,而不是依赖JSON验证。 - 引入更好的内置异常类型和错误处理。
- 使用JSON序列化库来创建请求有效负载,而不是使用
\JSONSerializable。 - 研究Rightmove RTDF的等效物。😇
安装
通过Composer
composer require lukeoliff/zpg-rtf-php
证书文件
在调用ZPG API之前,您需要遵循Zoopla的说明来生成用于对Zoopla服务器进行身份验证的公钥-私钥对。
一旦您向Zoopla提供了生成的证书签名请求文件,他们将验证并通过电子邮件提供证书。将证书与您生成的私钥结合
cat zoopla_provided_certificate.crt private.pem > combined.pem
将$pathToZpgCert变量更改为您的combined.pem文件的位置,您将准备好对ZPG服务器进行身份验证。
更新/创建列表
此方法允许您描述一个列表。它用于创建和更新目的,在任一情况下,列表都应完整描述。
use ZpgRtf\Methods\ListingMethod; use ZpgRtf\Objects\BranchObject; use ZpgRtf\Objects\ContentObject; use ZpgRtf\Objects\CoordinatesObject; use ZpgRtf\Objects\DescriptionObject; use ZpgRtf\Objects\EpcRatingsObject; use ZpgRtf\Objects\GoogleStreetViewObject; use ZpgRtf\Objects\ListingObject; use ZpgRtf\Objects\LocationObject; use ZpgRtf\Objects\PricingObject; $listing = new ListingObject(); $listing->setAccessibility(false) ->setBasement(false) ->setBathrooms(4) ->setBranchReference('branch-001') ->setBurglarAlarm(true) ->setCategory('residential') ->setCentralHeating('full') ->setChainFree(true) ->setConnectedUtilities(['electricity', 'fibre_optic', 'gas', 'satellite_cable_tv', 'water']) ->setConservatory(false) ->setConstructionYear(2015) ->setCouncilTaxBand('D') ->setDecorativeCondition('excellent') ->setDisplayAddress('Some Parade, Essex') ->setDoubleGlazing(true) ->setFeatureList(['Feature 1', 'Feature 2', 'Feature 3', 'Feature 4', 'Feature 5']) ->setFireplace(true) ->setFloorLevels(['ground', 1, 2]) ->setFloors(3) ->setGroundRent(99.99) ->setLifeCycleStatus('available') ->setListingReference('listing-000001') ->setLivingRooms(1) ->setLoft(true) ->setOutsideSpace(['private_garden', 'terrace']) ->setParking(['single_garage', 'off_street_parking']) ->setPropertyType('town_house') ->setRateableValue(12000) ->setSummaryDescription('A well decorated house.') ->setTenure('freehold') ->setTotalBedrooms(3) ->setUtilityRoom(true); $contentsImages = [ 'http://via.placeholder.com/800x600', 'http://via.placeholder.com/800x600/ffffff', 'http://via.placeholder.com/800x600/000000', ]; $contents = []; foreach ($contentsImages as $key => $image) { $content = new ContentObject(); $content->setUrl($image) ->setCaption('image: ' . $key) ->setType('image'); $contents[] = $content; } $listing->setContent($contents); $descriptionTexts = [ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ut fermentum justo. Sed id magna eu ante mattis semper. Vivamus purus lectus, sollicitudin vitae velit feugiat, porttitor rhoncus elit.', 'Integer rhoncus nulla quis nibh malesuada interdum. Nulla fermentum neque nec lacus ullamcorper fringilla. Mauris posuere quam nec erat accumsan, at sodales diam bibendum. Fusce vitae tortor purus.', ]; $descriptions = []; foreach ($descriptionTexts as $text) { $description = new DescriptionObject(); $description->setText($text); $descriptions[] = $description; } $listing->setDetailedDescription($descriptions); $epcRatings = new EpcRatingsObject(); $epcRatings->setEerCurrentRating(84) ->setEerPotentialRating(92); $listing->setEpcRatings($epcRatings); $coordinates = new CoordinatesObject(); $coordinates->setLatitude(52.0453067) ->setLongitude(0.7534206); $googleStreetView = new GoogleStreetViewObject(); $googleStreetView->setCoordinates($coordinates) ->setHeading(25.84) ->setPitch(76.92); $listing->setGoogleStreetView($googleStreetView); $location = new LocationObject(); $location->setPropertyNameOrNumber(9) ->setStreetName('Some Road') ->setLocality('Somefield') ->setTownOrCity('Somebury') ->setCounty('Somefolk') ->setPostalCode('SO10 2YA') ->setCountryCode('GB') ->setCoordinates($coordinates); $listing->setLocation($location); $pricing = new PricingObject(); $pricing->setCurrencyCode('GBP') ->setPrice(289995) ->setPriceQualifier('from') ->setTransactionType('sale'); $listing->setPricing($pricing); $pathToZpgCert = '../local/cert/file.pem'; $method = new ListingMethod($pathToZpgCert); $response = $method->sendUpdate($listing);
删除列表
此方法允许您从分支的库存列表中删除列表。
use ZpgRtf\Methods\ListingMethod; use ZpgRtf\Objects\ListingDeleteObject; $listingDelete = new ListingDeleteObject(); $listingDelete->setListingReference('listing-000001') ->setDeletionReason('withdrawn'); $pathToZpgCert = '../local/cert/file.pem'; $method = new ListingMethod($pathToZpgCert); $response = $method->sendDelete($listingDelete);
列出所有列表
由于该服务是增量性的,ZPG的数据相对于您的数据可能会漂移(例如,由于网络问题或未捕获的错误)。建议您定期检查他们系统和您系统之间数据的同步。列表/列表方法允许您检索分支的列表库存摘要及其状态。
use ZpgRtf\Methods\ListingMethod; use ZpgRtf\Objects\BranchObject; $branch = new BranchObject(); $branch->setBranchReference('branch-001'); $pathToZpgCert = '../local/cert/file.pem'; $method = new ListingMethod($pathToZpgCert); $response = $method->getList($branch);
更新/创建分支
此方法允许您描述一个分支,然后将其与列表相关联。地址和其他联系信息允许ZPG在我们的系统中识别等效分支并将您的branch_reference映射到它们。
use ZpgRtf\Methods\BranchMethod; use ZpgRtf\Objects\BranchObject; use ZpgRtf\Objects\CoordinatesObject; use ZpgRtf\Objects\LocationObject; use ZpgRtf\Objects\PafAddressObject; $branch = new BranchObject(); $branch->setWebsite('https://www.testagent.com/branch-name') ->setTelephone('02081111121') ->setBranchReference('branch-001') ->setBranchName('branch-name') ->setEmail('branch-name@testagent.com'); $branchLocation = new LocationObject(); $branchLocation->setPropertyNameOrNumber(9) ->setStreetName('Some Road') ->setLocality('Somefield') ->setTownOrCity('Somebury') ->setCounty('Somefolk') ->setPostalCode('SO10 2YA') ->setCountryCode('GB'); $branchCoordinates = new CoordinatesObject(); $branchCoordinates->setLatitude(52.0451852) ->setLongitude(0.7523342); $branchLocation->setCoordinates($branchCoordinates); $branchPaf = new PafAddressObject(); $branchPaf->setAddressKey('02341509') ->setOrganisationKey('00001150') ->setPostcodeType('S'); $branchLocation->setPafAddress($branchPaf) ->setPafUdprn('00001234'); $branch->setLocation($branchLocation); $pathToZpgCert = '../local/cert/file.pem'; $method = new BranchMethod($pathToZpgCert); $response = $method->sendUpdate($branch);
信誉
值得提的是,除了保持一致性之外,方法和对象描述直接引用自ZPG 实时列表服务文档。
贡献
许可
MIT 许可证 (MIT)。更多信息请参阅许可文件。