I have a script that worked great with v2 but broke when it expired and shifted to v3.
I've attempted to fix it but clearly there's more to it then just changing v2 to v3. Apparently they've deprecated secret token.
Here's what I have at the moment:
// Enter the path that the oauth library is in relation to the php file
require_once ('../lib/OAuth.php');
// For example, request business with id 'the-waterboy-sacramento'
$unsigned_url = "https://api.yelp.com/v3/businesses/search?term=niks-italian-kitchen-bar-austin";
// Set your keys here
$consumer_key = "xxxxxxx";
$consumer_secret = "xxxxxxxxx";
$token = "xxxxxxxx";
$token_secret = "xxxxxxxxxxx";
// Token object built using the OAuth library
$token = new OAuthToken($token, $token_secret);
// Consumer object built using the OAuth library
$consumer = new OAuthConsumer($consumer_key, $consumer_secret);
// Yelp uses HMAC SHA1 encoding
$signature_method = new OAuthSignatureMethod_HMAC_SHA1();
// Build OAuth Request using the OAuth PHP library. Uses the consumer and token object created above.
$oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url);
// Sign the request
$oauthrequest->sign_request($signature_method, $consumer, $token);
// Get the signed URL
$signed_url = $oauthrequest->to_url();
echo $signed_url;
// Send Yelp API Call
$ch = curl_init($signed_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch); // Yelp response
curl_close($ch);
// Handle Yelp response data
$response = json_decode($data);
// Print it for debugging
echo '<pre>';
print_r($response);
echo '</pre>';
A nudge in the right direction would be highly appreciated.
I'm getting an error:
stdClass Object ( [error] => stdClass Object ( [code] => TOKEN_MISSING [description] => An access token must be supplied in order to use this endpoint. ) )
Do I need to re-generate my API credentials for v3?