Google Places API: store Places in DB - database

I am building a web app where all the users belong to some type of places, lets say "bank". Each user belongs to only 1 bank but 1 bank can have more then one user.
I need to display their bank name and location in user profile and to be able to search by bank names inside specific city. So I need to connect users and banks somehow.
Is it safe to use the Place ID for that for each bank in terms of app scalability and life-cycle?
The manual says:
Place IDs are exempt from the caching restrictions stated in Section
10.5.d of the Google Maps APIs Terms of Service. You can therefore store place ID values indefinitely.
So Google says I can but is it the best practise? Do I need to store a full address additionally to be safe in case Google will deprecate these IDs in future?
Let's say I can get the bank Place ID with the help of Place Autocomplete during the user registration. Then I need to save it to DB to be able to display it later and search by bank.
The DB Structure could be:
Or Just
But I think the 1st way it better with unique place_id column?

As Google says, you may store PlaceID, but they also tell you that it is a good practice to "refresh" these stored PlaceIDs each 100 days, they do not assure you that your stored PlaceID will be for the same place that you stored.
https://developers.google.com/places/place-id

Related

FB Application with custom DB

2 quick question:
is it possible to build a Facebook application saving user profile informations (name, surname, phone numners, ecc.) on a external custom database (so, not FB database), obvioulsy after user approval, etc.
even if the answer of the above question is "no", do you know a way to pull out user profile information for all users who use the FB application and formally agree to give their personal information within the app? I would like to know if it is possible to do that both from a technical pov and legal pov
That´s what a privacy policy is for. In general, you should only store data after telling the user exactly what you store, what you do with the data, how long you store it and how he can get his entries deleted from your database.
Btw, you can´t get the phone number. About the technical way, please go to the Facebook docs: https://developers.facebook.com/docs

Can I include a custom payload or value with amazon affiliate links?

I'd like to be able to tag affiliate links with some extra information so that I can map successes to information inside of my system.
Is there any way I can include a custom identifier or payload of data with the affiliate link that Amazon will allow me to inspect when I receive a report of successful sales?
The only thing I found is the tracking ids from
Manage Your Tracking IDs page.
However this ids are limited to 100 values by default (you need to contact amazon for more). This is what they answered me:
I understand you'd like to view reporting within Products Advertising
API.
All reports are housed on your Associates account for you to view the
activity of your links.
We do offer multiple tracking IDs so that Associates can track the
activity of individual links easily and accurately.
You can create up to 100 tracking IDs in your account by visiting the
Account Settings section of Associates Central. You'll find a link in
the Account Information section labeled Manage your tracking IDs:
https://affiliate-program.amazon.com/gp/associates/network/your-account/manage-t...
Once you've created your additional tracking IDs, to view these IDs,
please log into Associates Central (http://associates.amazon.com).
Once logged in, click on the drop down box under Tracking ID to change
which ID you are working with.
If you are interested in receiving more than 100 tracking IDs, please
first create this amount via your associate account in Associate
Central. If you have already created 100 tracking IDs in your account
and are needing additional tracking IDs, please use the link below to
write back to us with a detailed description of how you'll be using
these additional ID:

How to avoid collisions with GAE Google user IDs?

Google App Engine provides user IDs from the Users service which are only promised to be:
an opaque string that uniquely identifies the user represented by this User object.
as per: https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/users/User#getUserId()
These strings always seem to be numeric with a length of 21 characters. Is there any guarantee from Google that they will always be numeric or any other promise more specific than just a String?
I ask because we'd like to store them alongside user IDs from other login providers such as Facebook and want to be sure that there will not be a collision if only the Facebook IDs have a prefix and the Google User IDs remain as is.
If you consistently add "g_" prefix to Google ids and "f_" prefix to Facebook ids, all ids will always be unique, even if you encounter a Google id that starts with "f_".
Note, however, that we decided against the approach that you are taking, because (a) users may change their accounts linked to our app (and we don't want to change their datastore id and update all references in such cases, even though it's a rare usecase), and (b) we allow users to connect more than one external account to an account in our app.
If you want to guarantee no collisions between IDs from multiple different providers/APIs, you should add prefixes to both types to ensure that. When an API says it's an opaque string, it is explicitly not making guarantees about what the content of the string may be. Just because it is consistently a number now doesn't mean it will continue to be a number in the future.

Sync google contacts by group to a limited number of users

I am trying to build an open-source python code hosted at GAE to sync contacts by group to a limited number of users. In a web interface users will be able to pick their group and whom it will be synced with.
I understand there is a lot of applications on market place withe the same functionality, but my organization is concerned about those provides selling contacts to 3rd parties. We are a non-profit organization, so the code could be hosted at google project or github for community contribution.
(sorry for the long intro)
How is the best way to start? is there tutorial available with similar functionality that I can expand?
What is the best way to compare two Contact kind elements? To see if they need to be sync.
Is there a last update on the Contact kind elements? In case I want to implement a last update wins?
thanks!
I don't know of any tutorials for syncing and comparing contacts specifically, but there is a getting started guide for the Google Contacts API at https://developers.google.com/google-apps/contacts/v3/.
The contacts are sent as XML blobs, so you could compare two contacts by parsing them and looking at the individual elements within them. I don't think there's a better way to do this but there are libraries to handle it for you.
There is a last updated field sent as part of the contacts when retrieving them with the API. It is an XML element labeled <updated>.
how are you getting different user's contacts feeds?
i tried to save the tokens in the datastore when the
users grant the access, but when i get the token back
from datastore for 2 users at a time, after an hour
when the token expires,
all tokens start working like the current users token
and i can only get current users contacts.
token = Get_Shared_User_Token(user_email)
contact_client = gdata.contacts.client.ContactsClient(source=USER_AGENT)
authorized_client = token.authorize(contact_client)
contacts_feed = authorized_client.GetContacts(q = query)
can you please tell how one can get any user's contacts?

Geocoding out of Salesforce.com (large number of static adresses)

We have developed an application in Salesforce.com to geocode and display account information (address information) on Google Maps within Salesforce.com. We have around 750k addresses for the initial (one-time) geocoding process (static address data), as we store the lat/lon with the account.
Is their any way to get this geocoded done in one 'batch' as we seem to hit the daily allowance of request per day (3k)?
Thanks for your support and feedback.
If you'd like to use Google to do this and you need to precompute the lat/lon coordinates, you'll need to upgrade to the Google Maps API for Business. The table on that link provides a detailed overview of the limit differences, and I suspect that the terms of use may also be more in line with what you're developing too.
If your goal is to create a Google Map from the addresses, you may also consider just passing the address data instead of the latitude and longitude. Their static maps will work fine as long as you know which locations that you'd like to use on the map, you don't have too many locations in one map and you don't need interactivity. Otherwise, you should use the javascript API and their documentation is very good for that.
If you don't know which locations you'd like to use on the map, you could use the lat/lon coordinates of their zip codes (which are freely available) to create a view port.
If you'd like a static map of the locations (whether or not you precompute the lat/lon), I'd recommend taking a look at the apexgooglestaticmap Github repository. It makes it quite easy to make certain types of static Google maps in APEX and VisualForce. Here's an example from that README:
APEX Controller
String[] homes = new String[]{'Albany, NY','Wellesley, MA','New York, NY','Pittsburgh, PA','01945','Ann Arbor, MI','Chicago, IL'};
GoogleStaticMap.MapPath moves = new GoogleStaticMap.MapPath(homes).color('0x000000ff');
String movesUrl = new GoogleStaticMap().addPath(moves).url;
Visualforce Page
<apex:image value="{!movesUrl}">
Google Maps URL and Image
https://maps.google.com/maps/api/staticmap?sensor=false&size=500x350&markers=label:0%7CAlbany%2C+NY&markers=label:1%7CWellesley%2C+MA&markers=label:2%7CNew+York%2C+NY&markers=label:3%7CPittsburgh%2C+PA&markers=label:4%7C01945&markers=label:5%7CAnn+Arbor%2C+MI&markers=label:6%7CChicago%2C+IL&markers=label:0%7CAlbany%2C+NY&markers=label:1%7CWellesley%2C+MA&markers=label:2%7CNew+York%2C+NY&markers=label:3%7CPittsburgh%2C+PA&markers=label:4%7C01945&markers=label:5%7CAnn+Arbor%2C+MI&markers=label:6%7CChicago%2C+IL&path=weight:5%7Ccolor:0x000000ff%7CAlbany%2C+NY%7CWellesley%2C+MA%7CNew+York%2C+NY%7CPittsburgh%2C+PA%7C01945%7CAnn+Arbor%2C+MI%7CChicago%2C+IL&
There are also many other geocoding APIs available. They each have their own terms of service, so make sure that your application matches the acceptable uses before you build anything with them. I've personally used PCMiler Web Services with success, and Geonames for reverse geocoding (they have a number of other great features too).
Google only allows that max per IP Address. If you were able to maximize the locations you were doing them from, max out at work, home or maybe your local starbucks, you could be able to hit the goal easily. If you have more than 250 employees just assign the 'homework' of going home and geocoding it! Spread the wealth, and the fun, of geocoding!
The other solution is using Google Maps API For Business, which allows you to do a max of 100,000 requests per day. For more information look at: http://code.google.com/apis/maps/documentation/geocoding/ ; for more information specifically on Geoogle Maps API For Business: http://code.google.com/apis/maps/documentation/business/index.html
I use this geocoder, and add my list and use yahoo to get the lat and long.
We have FindNearby installed, so once I get all the addresses geo-coded, I add them back into my excel worksheet in the respective column that has the Record ID. Since we use FindNearby, I have to add a column that is titled Mapping Status, and all cells under this say Located. I used ApexData loader to mass upload into SF. Note, geocoder has a limit of only 1000 records at a single "code" click, but it has no limit of how many lists you can process per day.
I changes some code to use Bing map services instead of google. There limits are based on keys and are much larger. Also when the key hits its max requests, then you can just get a new free key and apply it.

Resources