承接 fehrlich/immoscout24-api-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fehrlich/immoscout24-api-php

最新稳定版本:v0.3.1

Composer 安装命令:

composer require fehrlich/immoscout24-api-php

包简介

PHP Client for interacting with the Immoscout24 REST API

README 文档

README

An example implementation for the immoscout24 rest api in php. This Client is not complete and only implements some methods for the export/import api, but it should be quite easy to extend.

install

composer install fehrlich/immoscout24-api-php

usage

The libary contains an abstract class that needs to be extended by an user defined class and implement 4 methods, that are needed to restore and save tokens.

example implementation

class MyAPI extends \fehrlich\ScoutAPI\ImmoScoutAPI
{
    /**
     * should save the request token with tokenname + secret, the token can be temporarily saved within a session
     * this token is only needed during the "request an access token" phase.
     *
     * @param string $token
     * @param string $secret
     *
     * @return void
     */
    public function saveRequestToken($token, $secret){
        $_SESSION['is24reqtoken'] = $token;
        $_SESSION['is24reqsecret'] = $secret;
    }

    /**
     * restores the temporarily saved request token.
     *
     * @return array with 2 elements: first element is the token name, second element is the secret
     */
    public function restoreRequestToken(){
        if(isset($_SESSION['is24reqtoken']) && isset($_SESSION['is24reqsecret'])){
            return [
                $_SESSION['is24reqtoken'],
                $_SESSION['is24reqsecret']
            ];
        }
        return null;
    }

    /**
     * saves the access token, the information should be stored persistently, for example in a database or file.
     * the progress of getting an access token only needs to be done once per user.
     *
     * @param string $token
     * @param string $secret
     *
     * @return void
     */
    public function saveAccessToken($token, $secret){
        file_put_contents('accessToken', serialize([$token, $secret]));
    }

    /**
     * restores the saved access token.
     *
     * @return array with 2 elements: first element is the token name, second element is the secret
     */
    public static function restoreAccessToken(){
        if(file_exists('accessToken')) {
            return unserialize(file_get_contents('accessToken'));
        }
        return null;
    }
}

If you want to support multiple user, you can use $this->getUser() within the class.

example usage

$key = 'my consumer key';
$secret = 'my consumer secret';

// $api->dontUseSandbox();

$api = MyAPI::createClient($key, $secret);
if ($api->isVerified()) {
    // get a list of possible contacts used in a real estate
    $contactArray = $api->getContacts();
    var_dump($contactArray);
} else {
    // this will trigger the verifiaction with immoscout24, and will try to reconnect
    // to the current url else you can also use a paramater to specify the callback url
    $api->verifyApplication();
}

统计信息

  • 总下载量: 4.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-30