This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-yelp-api.php
172 lines (147 loc) · 3.26 KB
/
wp-yelp-api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/**
* WP Yelp API (https://www.yelp.com/developers/documentation/v2/overview)
*
* @package WP-Yelp-API
*/
/*
* Plugin Name: WP Yelp API
* Plugin URI: https://github.com/wp-api-libraries/wp-yelp-api
* Description: Perform API requests to Yelp API in WordPress.
* Author: WP API Libraries
* Author URI: https://wp-api-libraries.com
* Version: 1.0.0
* GitHub Plugin URI: https://github.com/wp-api-libraries/wp-yelp-api
* GitHub Branch: master
*/
/* Exit if accessed directly */
if ( ! defined( 'ABSPATH' ) ) { exit; }
if ( ! class_exists( 'YelpAPI' ) ) {
/**
* YelpAPI class.
*/
class YelpAPI {
/**
* consumer_key
*
* (default value: '')
*
* @var string
* @access public
* @static
*/
static $consumer_key = '';
/**
* consumer_secret
*
* (default value: '')
*
* @var string
* @access public
* @static
*/
static $consumer_secret = '';
/**
* token
*
* (default value: '')
*
* @var string
* @access public
* @static
*/
static $token = '';
/**
* token_secret
*
* (default value: '')
*
* @var string
* @access public
* @static
*/
static $token_secret = '';
/**
* Base URI.
*
* @var string
* @access protected
*/
protected $base_uri = 'https://api.yelp.com/v2/';
/**
* Construct.
*
* @access public
* @param mixed $api_key API Key.
* @param mixed $output Output.
* @return void
*/
public function __construct( ) {
}
/**
* Fetch the request from the API.
*
* @access private
* @param mixed $request Request URL.
* @return $body Body.
*/
private function fetch( $request ) {
$response = wp_remote_get( $request );
$code = wp_remote_retrieve_response_code( $response );
if ( 200 !== $code ) {
return new WP_Error( 'response-error', sprintf( __( 'Server response code: %d', 'text-domain' ), $code ) );
}
$body = wp_remote_retrieve_body( $response );
return json_decode( $body );
}
/**
* search function.
*
* @access public
* @param mixed $term
* @param mixed $limit
* @param mixed $offset
* @param mixed $sort
* @param mixed $category_filter
* @param mixed $radius_filter
* @param mixed $deals_filter
* @param mixed $location
* @param mixed $bounds
* @param mixed $latitude
* @param mixed $longitude
* @param mixed $accuracy
* @param mixed $altitude
* @param mixed $altitude_accuracy
* @param mixed $cc
* @param mixed $lang
* @param mixed $actionlinks
* @return void
*/
public function search( $term, $limit, $offset, $sort, $category_filter, $radius_filter, $deals_filter, $location, $bounds, $latitude, $longitude, $accuracy, $altitude, $altitude_accuracy, $cc, $lang, $actionlinks ) {
}
/**
* get_business function.
*
* @access public
* @param mixed $business_id
* @param mixed $cc
* @param mixed $lang
* @param mixed $lang_filter
* @param mixed $actionlinks
* @return void
*/
function get_business( $business_id, $cc, $lang, $lang_filter, $actionlinks ) {
}
/**
* phone_search function.
*
* @access public
* @param mixed $phone
* @param mixed $cc
* @param mixed $category
* @return void
*/
function phone_search( $phone, $cc, $category ) {
}
}
}