sabana15/yelp-fusion-api-php

PHP 对 Yelp API v3 的包装器

1.3 2021-06-17 08:19 UTC

This package is not auto-updated.

Last update: 2024-09-20 13:38:49 UTC


README

安装

# 注意:如果你已经安装了 guzzle 包,请忽略此 guzzle 包

  1. 你可以使用 Composer 将其添加为依赖项

    composer require guzzlehttp/guzzle:^6.0

    composer require sabana15/yelp-fusion-api-php

  2. 或者,你可以在项目中现有的 composer.json 文件中指定为依赖项

    {

     "require": {
    
         "guzzlehttp/guzzle:^6.0",
    
         "sabana15/yelp-fusion-api-php": "1.0"
    
     }
    

    }

用法

此包仅支持 Yelp Fusion API v3

创建 Yelp API 客户端

$yelpFusion = new TrialAPI\YelpClient('将 API 密钥放在这里');

根据搜索参数获取业务

$param = array('location' => 'xyz');

$businessSearchList = $yelpFusion->getBusinessesSearchResults($param);

PHP 示例

创建文件 index.php 并将以下内容放入其中。

require 'vendor/autoload.php';

try{

$apikey = 'API key goes here';

$yelpFusion = new TrialAPI\YelpClient($apikey);

$param = array('location' => 'melbourne');

$businessSearchList = $yelpFusion->getBusinessesSearchResults($param);

var_dump($businessSearchList);

}

catch(Exception $e) {

echo $e->getResponseBody();

}

在终端中运行 'php index.php' 以检查,或在浏览器中访问并检查