realestateconz/api-client

1.1.0 2023-05-16 22:14 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:35:47 UTC


README

使用realestate.co.nz api客户端最简单的方式是将它作为Composer包安装到项目中。

如果您不熟悉Composer,请参阅https://getcomposer.org.cn/

  1. 将realestateconz/api-client添加到您的应用的composer.json文件中。

     {
         ...
         "require": {
             "realestateconz/api-client": "dev-master"
         },
         ...
     }
    
  2. 运行composer install

  3. 如果您还没有做,请在项目的初始化文件中添加Composer自动加载。(示例)

     require 'vendor/autoload.php';
    

创建API签名

GET请求

$client = new RealestateCoNz_Api_Client('PRIVATE_KEY', 'PUBLIC_KEY', 1);
$api_path = '/listings/';
$query_params = array('format' => 'full');
$api_signature = $client->createSignature($api_path, $query_params);

POST请求

$client = new RealestateCoNz_Api_Client('PRIVATE_KEY', 'PUBLIC_KEY', 1);
$api_path = '/listings/100000000/agent-enquiry/';
$query_params = array();
$post_values = array('email' => 'example@example.com', 'phone' => '000000000', 'text' => 'test', 'name' => 'Test');
$api_signature = $client->createSignature($api_path, $query_params, $post_values);

注意:所有POST请求都必须使用以下请求头发送

Content-Type: application/x-www-form-urlencoded