Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sean-park
Copy link

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.

@tomelm
Copy link
Contributor

tomelm commented Mar 21, 2017

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?

@sean-park
Copy link
Author

sean-park commented Mar 21, 2017 via email

@sean-park
Copy link
Author

Hey @tomelm, I removed the client id & secret.

Copy link
Contributor

@watterso watterso left a 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
Copy link
Contributor

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)
Copy link
Contributor

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")
Copy link
Contributor

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")
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants