Git Product home page Git Product logo

reso-webapi-client-php's Introduction

RESO WebAPI Client PHP SDK

The RESO WebAPI Client PHP SDK for PHP allows developers to build applications with RESO API queries for listing data retrieval. For more information on the Real Estate Standards Organization (RESO) please visit www.reso.org or contact [email protected]. Developers wishing to better understand how to use and contribute to our standards visit RESO Developers FAQ.

Specific questions about this repository should be posted to the 'Issues' section with the Issue Template.

Requirements

PHP 5.3.3 and later.

Composer

You can install the bindings via Composer. Run the following command:

composer require reso/reso-php

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/reso-php-sdk/init.php');

Dependencies

The following PHP extensions are required for all the RESO WebAPI Client PHP SDK functions to work properly:

If you use Composer, these dependencies will be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Getting Started

Simple usage looks like:

// Set the variables
RESO\RESO::setClientId('YOUR_CLIENT_ID');
RESO\RESO::setClientSecret('YOUR_CLIENT_SECRET');
RESO\RESO::setAPIAuthUrl('https://op.api.crmls.org/identity/connect/authorize');
RESO\RESO::setAPITokenUrl('https://op.api.crmls.org/identity/connect/token');
RESO\RESO::setAPIRequestUrl('https://h.api.crmls.org/RESO/OData/');
// Authorize user
$auth_code = RESO\OpenIDConnect::authorize('YOUR_USERNAME', 'YOUR_PASSWORD', 'https://openid.reso.org/', 'ODataApi');
// Get access token
RESO\RESO::setAccessToken(RESO\OpenIDConnect::requestAccessToken($auth_code, 'https://openid.reso.org/', 'ODataApi'));
// Set the Accept header (if needed)
RESO\Request::setAcceptType("json");
// Retrieve top 10 properties from the RESO API endpoint
$data = RESO\Request::request('Property?\$top=10', 'json', true);

// Display records
print_r($data);

Example apps

Several usage examples are provided in the examples/ folder:

  • cli-example - provides a sample console application to query RESO API data;
  • web-example - provides a sample PHP + HTML application to login (auth done on server-side) and execute RESO API requests, retrieve the data;
  • web-callback-example - provides a sample PHP application, which demonstrates the user auth using callback URL.

To configure the example app variables / settings - copy the config.php file in each example application as _config.php and edit the variables accordingly.

Configuring a Logger

The SDK has a built-in logger for debug / testing purposes. Usage:

// Set logging
RESO\RESO::setLogEnabled(true); // enables logging in general. Default: false.
RESO\RESO::setLogConsole(true); // enables log messages to console.
RESO\RESO::setLogFile(true); // enabled log messages to be written to log file.

Unit Tests

The SDK code set contains PHPUnit tests. The tests reside in the tests/ folder and covers core RESO WebAPI Client PHP SDK functionality testing.

To run the tests duplicate the tests/config.php file to tests/_config.php and set the appropriate API variables. Then, execute:

./vendor/bin/phpunit --bootstrap init.php tests/

Contributing

Please read the contributing guidelines if You are interested in contributing to the project.

reso-webapi-client-php's People

Contributors

bobgott avatar ch3k1 avatar mindaugaskiznis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.