I am looking to create a mobile friendly input where a user can input 2 different zip codes (origin zip & dest zip), they are returned information from a Database about those zips.
Companies like Fedex and UPS use zip code ranges to determine shipping information.
So it would need to search about 60,000 line items to find the exact range that fits both zip codes, and then returns the 5 values that are on the right.
The link below is a screen shot of what excel looks like and the data wanted to return
Screenshot
So if the origin zip was (for example) 33705 and the destination was 31601, it would search the origin range and the destination range, and return
3
303
203
133
103
After that works, then will move on to do bigger and better things... but this is the first step.
What is the best way to code something like this?
Web services are what you're looking for. Create web services that will interact with your database. Whenever your user enter origin and destination zip then call the service and send these entered zip codes as parameters of web service. Services will do rest of the computation i.e. finding 5 zip codes in between the given zip codes and returning the result back to the user.
Related
I have created a React Native app and want a function where the user can specify in which city they live so that it can be shown to other users. It should be a text input where the user can search for a city and get a dropdown of choices to choose from. The city should then preferably be saved as an ID in our database that can be converted back to a localized version of the city for all users. Let's say someone lives in the UK it should say Gothenburg and if you live in Sweden it should say Göteborg. I have looked at the following options but none is optimal for us:
Google Places Autocomplete API to fetch the city, save the place ID in our database, and reverse geocode it. This becomes very expensive for us because it is a social app and each user would do approximately 20 geocoding requests when starting the app
Create a database with names of cities. This is not very scalable as you need to add new entries for each new country you want to support
Let users manually enter their city. This is prone to errors because users can write whatever they want
I would be happy to receive some suggestions on how to solve this issue.
Here are the things you currently want:
Provide your users an Autocomplete functionality
Get the city based on their selection
Save the city and store it on your database
provide users a localize text of the city they chose
For the third one, storing the city provided by the API may not be allowed by Google. I can see that you are aware of the terms, but here is the Service Specific Terms of what is allowed to be cached.
Depending on your use case tho, this can still be doable. In terms of pricing and efficiency, see this pricing sheet for your reference. Right now, you are doing Places Autocomplete and Reverse Geocoding the selection to get the City. You are actually paying a little more. Assuming that you are even using per session autocomplete, this is what you are paying for every 1000 request:
Autocomplete without Places Details - Per Session = $17.00 +
Geocoding API = $5.00
Total Cost: $22 per thousand calls
So instead of using Reverse Geocoding, you can instead use Place Details which serves the same purpose. The city can be retrieve on a Place Detail request which is under the Basic Data, with the Address Component field. See this link for the list of fields Place Details can retrieve. When retrieving fields with Basic Data, those are free of charge, unlike Contact and Atmosphere Data. So make sure to make use of the "fields" parameter for the Place Detail request that you will use as if you did not specify that, all Data will be retrieve and you will be charged accordingly. So if you use that with Autocomplete, your cost now will be:
Autocomplete (included with Places Details) - Per Session + Places Details + Basic Data = $17.00 per thousand calls
Now that you have the City, you would now want to present it in the customer's local language. Place Details contains the optional parameter "language". And by simply getting the customer's current language in the device, you can achieve this. Here is how you can get it for your reference.
My company has a social networking platform that is accessed via a URL.
We are trying to find a way to advertise our URL in sports stores, with access to our site only possible if you come to the store - we do not want the sharing of the URL to anyone, anywhere.
We have considered QR codes and wonder if it's possible our site can only be accessed when a provided QR code is scanned.
Please let me know if you have any suggestions.
You are basically looking for keys/ access codes that give your customers access to a site.
Those might have to be on a per-user basis, as otherwise one might just leak an access code for the whole public to use.
If sharing keys should be disallowed:
You need a database (sql) to store your cusstomers' information.
Depending on how you generate a key (dynamically, by a set of rules or randomly, using a catalogue of valid keys) you might need a further table to store the keys separately (in case you choose the more secure option of generating a predefined set of random keys)
You can then include those keys in your QR Codes' target URL like www.example.com?key=1jh303u or something similar.
(This means of course that you have to produce customized QR Codes, which in turn means they cannot be printex as a standard mass-produced offset job, but as a customized digital print - so you'd have to send all the different generated QR Codes to your printer)
Once the user visits this URL containing the query string, your site can then check to see if the key is a) valid (in the table) and b) unused, by taking the &_GET["key"] variable and querying the database.
If the key is invalid, output an "access denied" page.
If the key exists but has already been checked in, you can use a user-based login system to handle the login.
If the key is valid and hasn't been used yet, you can output your exclusive content at last.
If it doesn't matter whether people will be able to share their key, you don't need a database at all. You could build a keygen which creates keys after a certain destinct pattern, and use that same set of rules to validate against the entered key.
what happens when a Facebook page is queried for its feed with Facebook Graph API (JS SDK) and a URL parameter fields (like for the post object) is added?
I would like to load from the feed only the posts id's, shares, likes and comments, because the page is pretty active and the text data in JSON for 2 days is about 2MB (25 items)...
I would hope one could do like this: FB.api('/SomePage?fields=id,shares,likes'), but I suppose the only fields you can access are the direct children (for feed, that is data & paging)? If this unfortunately is the case, is there any other way to retrieve all posts from date x to date y without downloading the entire feed?
That's not correct. The feed edge is basically an array of Post objects. You can use the Field Expansion together with time pagination as follows:
GET /{page_id}/feed?fields=id,shares,likes.summary(true)&since={start_unix_timestamp}&until={end_unix_timestamp}
See
https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed/#read
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#fieldexpansion
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging
I've tried a few different ways trying to get this to work. So essentially I have a list of parks that I pull with one $http get method, each park object has a weather field inside of it. After the initial load I am trying to parse non-restful .json files with the weather status (pulled by a background process server side) and do an association with the weather object based on zipcode.
So there are about 30 parks. The way I pulled the weather info on the background (so as to not hit the rate limit) was to just pull them for each zipcode (relative to park location) and place them in a file named by zipcode. So for example 90201.json, 08291.json, etc
I've tried doing something like this so far: http://plnkr.co/edit/66BjKESPnYGWgQwOzEPN?p=info
But I think I'm probably messing up in a few places, any advice would be greatly appreciated.
Thanks!
I'm working on a sharepoint farm that has User Profiles enabled. We're creating a community feature which has a profile wall of all members of that community. I need to retrieve and display profile pictures from a search based source and display the results as they are returned in an appealing efficient way.
We have two avenues:
1: FAST search indexes the profiles of every user every 6 hours. We can run a membership query and return all members of [x] community.
2: We can use the profile API to do a search. This is slower but does not rely on the 6 hour index and therefore gives us up to date information.
We need to make this call via JavaScript, as sever side code is locked down and not an option. I'd like to write a function that calls these profiles and loads the images into a wall one at a time as they are retrieved. Possibly in a timed loop, so an image loads every 100 milliseconds.
I believe profile photos are stored as a text property containing the photo URL, so the URL can be set as an images source.
How would I go about quickly loading a set of images asynchronously to provide a good user experience?
Since you do not have server side code option, I would suggest you to go for a Jquery Script which would render these images. This javascript code can be loaded asynchronously as suggested in this article:
https://wiki.base22.com/display/btg/How+to+load+JavaScript+dynamically+with+jQuery