-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Java sample code for yelp-fusion Api #171
base: master
Are you sure you want to change the base?
Conversation
link to documentation page was broken
Hey @sean-park, your client id and secret were committed into the PR. I've disabled the client right now since the credentials are publicly exposed so you'll want to reset them. Mind removing them from the PR? |
Hi, Tomer Elmalem. I don't mind remove them. Thanks!
…On Tue, Mar 21, 2017 at 10:48 AM Tomer Elmalem ***@***.***> wrote:
Hey @sean-park <https://github.com/sean-park>, your client id and secret
were committed into the PR. I've disabled the client right now since the
credentials are publicly exposed so you'll want to reset them. Mind
removing them from the PR?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#171 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALDD3fWmGypERo7x65QR94be6tMgEyvsks5roA18gaJpZM4MD0mX>
.
|
Hey @tomelm, I removed the client id & secret. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great simple example of how to query the api in Java, thanks!
The changes I requested are mostly around migrating to our new authentication method, otherwise looks good!
public static void main(String[] args)throws JSONException, IOException { | ||
|
||
|
||
// POST https://api.yelp.com/oauth2/token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the oauth2 endpoint is no longer necessary, more details here could you delete this section?
Request request2 = new Builder() | ||
.url("https://api.yelp.com/v3/businesses/search?term=" + term + "&location=" + location + "&limit=1&sort_by=rating&price="+price+"") | ||
.get() | ||
.addHeader("authorization", "Bearer"+" "+accessToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you replace accessToken
with apiKey
, a string that is by default defined as "<YOUR_API_KEY>"
, to make the query compatible with our new authentication
.url("https://api.yelp.com/v3/businesses/search?term=" + term + "&location=" + location + "&limit=1&sort_by=rating&price="+price+"") | ||
.get() | ||
.addHeader("authorization", "Bearer"+" "+accessToken) | ||
.addHeader("cache-control", "no-cache") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you delete this header? It is not needed to query the API, we want to show an example of what the minimum is needed to query the API
.get() | ||
.addHeader("authorization", "Bearer"+" "+accessToken) | ||
.addHeader("cache-control", "no-cache") | ||
.addHeader("postman-token", "b5fc33ce-3dad-86d7-6e2e-d67e14e8071b") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you delete this header? It is not needed to query the API, we want to show an example of what the minimum is needed to query the API
I implemented the yelp authentication in Java. I followed by yelp v3 documentation to implement this.
I generation token first, then output simple search using the token.