Open meandmyselfinoneperson opened 7 years ago
Hi @meandmyselfinoneperson . That generally occurs when there is a timeout or a bad network connection. Are you still receiving the same error?
Hi @meandmyselfinoneperson
Are you still running into this error?
Hi @chrisdhaan
Thanks for creating this framework! I was trying to write all this from scratch--awful.
I am actually get this error after implementing it though. This is my printout:
2018-03-15 18:30:13.698594-0700 MartiniFinder[88660:7097856] Could not inset legal attribution from corner 4 2018-03-15 18:30:13.758028-0700 MartiniFinder[88660:7097948] Task <FE5858E7-60C6-40A2-B506-99FE2DC03484>.<1> finished with error - code: -999 2018-03-15 18:30:13.758155-0700 MartiniFinder[88660:7097894] Task <FE5858E7-60C6-40A2-B506-99FE2DC03484>.<1> HTTP load failed (error code: -999 [1:89]) searchBusinesses(byTerm) failure: cancelled
@Pigpocket could I get some more context into what you are trying to do? What OS are you using? you don't have to share the project but could you at least share the call you are trying to make in a Markdown code block?
Hey @chrisdhaan
I'm happy to share the code, it's for a capstone project in a class I'm taking. FYI: I have a whole bunch of organic network code in this project from me trying to build it from scratch... you can just ignore that as it is not related to the error:
https://github.com/Pigpocket/MartiniFinder
This is the specific call, I dropped the apiKey of course:
`let yelpAPIClient = CDYelpAPIClient(apiKey: apiKey)
yelpAPIClient.searchBusinesses(byTerm: "martini", location: nil, latitude: MapCenter.shared.latitude, longitude: MapCenter.shared.longitude, radius: 16000, categories: nil, locale: nil, limit: 20, offset: nil, sortBy: nil, priceTiers: nil, openNow: true, openAt: nil, attributes: nil) { (response) in
if let response = response,
let businesses = response.businesses,
businesses.count > 0 {
print("***These are the yelpAPIClient businesses printed: \(businesses)")
}
}`
@chrisdhaan I didn't mention this is in iOS 11.1. Let me know if you need any more info. Thanks,
Apologies for the slow response @Pigpocket. Had a busy weekend. Looking into this today.
@chrisdhaan No worries! Just glad this repo exists!
@Pigpocket I looked in your repo on the YelpWrapper
branch and I could not find that code. Could you point me to what class I should be looking at?
Whoops! I hadn't committed it yet. Take a look meow and let me know if you see it. It's in the MapViewController.
Hey @chrisdhaan let me know if there's any other information you need. Your repo seems perfect and I'm trying to implement it as soon as possible!
@Pigpocket I don't have the ability to commit the changes that will fix you code to the repo. I've opened issues. Fix the issues and your code will work.
@chrisdhaan thanks for that, I see those and have made the changes but am getting: "searchBusinesses(byTerm) error: An access token must be supplied in order to use this endpoint."
I detailed that in the issue on my repo and added you as a collaborator. Thanks so much for your help!
@Pigpocket I'm not doing your homework for you. This is not an error with a framework. I was able to get businesses returning in your project.
@chrisdhaan sorry, I wasn't asking for that. I was just curious if your code was built on using the OAuth 2.0 system, as Yelp discontinued use of tokens as of March 1st. I'll try to figure it out on my own. Thanks for your help.
@Pigpocket the framework is updated for the most up to date authorization system documented by Yelp. I apologize for being short with you but I work full time and develop this framework in my free time for fun. I don't have the time to help with your project.
This framework comes with an iOS Example project that works and shows how to use the framework. Have you looked at that?
@chrisdhaan I got it to work in my project, thanks.
I'm curious how to access the isOpenNow property of a business. I can get other properties like id and name via dot notation (business.id, business.name), but I can't seem to get the isOpenNow bool. I see it is an array of type CDYelpHour and I attempt business.hours[0].isOpenNow but I get a nil value. I've tried with different indexes as well without any luck. How do I get that?
@Pigpocket you won't get access to the hours of a business unless you do an additional API request using the business lookup call. The search call does return businesses, but they do not have all of their information filled in. For an example of the differences in data the two API calls return, see the documentation on the Yelp Developer site for the two endpoints. Business Search:
https://www.yelp.com/developers/documentation/v3/business_search
Business Lookup:
Hey @davecom,
Ok. I actually originally wrote my own code to make both of those calls separately, one after the other. My second call runs up against the API's QPS rate-limiting. I'm new to networking, but that strikes me as a bit odd... trying to get the isOpenNow property, for say, 20 businesses doesn't seem like it would be hugely taxing on the server (but that could just be because I don't fully understand it).
After reading up more on the graphQL type API, my impression was I could embed the second call into the first. My research brought me to this framework, and I was under the impression that's what this framework was doing--though admittedly I'm not entirely sure how--in particular because the CDYelpBusiness class has the 'hours' variable.
This is what a Yelper told me on Github:
Hi @Pigpocket, regarding using the GraphQL API to retrieve business hours in a single request rather than a second call after getting the business ID, you're correct; that's the essence of GraphQL -- that you can define what your response looks like.
As for the 429, it's also possible that you're hitting a QPS rate limit. We limit developers to 5 QPS and if this is the case, your error message should look like this:
So... sounds like I will need to make the second API call when using this framework if I want the business hours. I guess I'm just confused because they seem to indicate the second call isn't necessary, but I'm ok sending it so long as I "slow down my requests"
Sorry for the novel.
@Pigpocket This framework does not use the GraphQL API. If you want to do that, you'll need to do that outside of the framework. Using Yelp Fusion (as this framework does) you need two calls (search + business lookup) to get a business's hours. So, yes if you are doing a search (1 API call) and then immediately 20 business lookups (20 more API calls) then you would be exceeding the Yelp limit of 5 API calls/second.
PS If all you are interested in is finding out what businesses are open now, there is an option for filtering by that in the search endpoint.
@davecom,
Ok, awesome... that answers my question. Thanks!
I do recognize that there is an option to filter only businesses that are open at the moment, but that doesn't align with the intended use case for my app.
Thanks for the quick feedback... I know this framework has no commercial component, so I appreciate all the support you and @chrisdhaan have given me so far. Feel free to ignore my questions below, as they don't really fall under the category of "issue", but if/when you have the time, I'm curious....
I know you didn't design the Yelp API, but why would isOpenNow be buried in a second call? Is there an obvious reason for that API architecture?
Do you have an intention to update this framework to take advantage of the graphQL framework? How significant of a development effort would that be?
Thanks again. It's definitely been a learning experience inspecting your code and I know I have a lot to learn!
@Pigpocket In response to your first question, I don't know and you would have to ask the Yelp developers. My guess is that they want to keep the amount of bandwidth used by the search API, since it returns multiple businesses at once, limited to essential information.
In response to your second question, you would have to ask @chrisdhaan since it's his framework. However, it would be a huge undertaking and my guess is he won't be doing that.
Yep, makes sense.
Thanks again to you both and whoever else helped build and/or support this framework.
I had the same issue. For me It was trying to access the client before it was finish intializing, i forgot to init the singleton in the app delegate : try adding the below call in the app delegate method: didFinishLaunchingWithOptions CDYelpFusionKitManager.shared.configure() or whatever call you use to init the client with your token.
I am still having this issue:
2018-07-12 22:24:02.526719+0100 lineare[2979:766204] Task <C3EB35DC-3813-4C8F-8D3C-8A73A323F753>.<1> finished with error - code: -999
2018-07-12 22:24:02.526788+0100 lineare[2979:766204] Task <ECCD140C-4BB6-45ED-AE71-52A4782C30C4>.<2> finished with error - code: -999
searchBusinessMatches(byType) failure: cancelled
The call I make is:
let yelpAPIClient = CDYelpAPIClient(apiKey: self.yelpApiKey);
yelpAPIClient.searchBusinesses(byMatchType: .lookup, name: "Henri", addressOne: nil, addressTwo: nil, addressThree: nil, city: "Edinburgh", state: "SCO", country: "GB", latitude: nil, longitude: nil, phone: nil, postalCode: nil, yelpBusinessId: nil, completion: { (response) in
if let response = response, let businesses = response.businesses {
print(businesses);
}
})
How can I solve it? And thanks for the repo, once I get it to work it will be super handy.
@snowzurfer Late answer but I just installed this pod and noticed that if I made the request right after initializing the CDYelpAPIClint(apiKey:)
, I got the same error. I moved calling this function (searchBusinesses) at a later stage, after the rootViewController did load and it worked fine after that. I guess we have to make sure to call searchBusiness (or any other call I would say) once we know that the yelpAPIClient is fully instantiated.
Hi Christopher,
thanks for sharing the CDYelpFusionKit.
With my Xcode 9.1 and Swift 3 installation I run in a network issue after I am authorized and my parameters (e.g. for search) are transferred: finished with error - code: -999 searchBusinesses(byTerm) failure: cancelled
It seems there is an issue in the CDYelpAPIClient.swift with
I tried hard to find out but couldn't finally solve the issue.
Do you have any idea?