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.
Related
Google map post code doesn't show exact address using Google maps API! For example if I search a nw107ns it shows park royal as formated_address which is a big place while it should show Middlesex center hospital.
Am using Google map API with restrictions to UK only.
Your answers are appreciated!!!
If you are using Geocoding API, please note that this API meant to convert complete addresses to lat-lng coordinates. Providing only the postal code and the country will give you the details of the postal code NW10 7NS. To get the address of Middlesex center hospital, you must at least include the name of the establishment on your API request to make it more specific.
Like this:
https://maps.googleapis.com/maps/api/geocode/json?address=Middlesex%20center%20hospital&components=country%3AGB®ion=GB&key=YOUR_API_KEY
When using Geocoding API, make sure to adhere to Geocoding Best Practices.
If you are using autocomplete, generally Place autocomplete will return a list of places matching the user's input. If you input NW10 7NS, the autocomplete will return the the place of type postal code since this matches the user's input. If ever you filter the results by type(e.g establishment), the autocomplete will only return places with names or addresses that matched the users input. In the case of NW10 7NS, the API will not return anything since there's no place of type establishment named "NW10 7NS".
Here's a sample Place Autocomplete implementation you can refer to: https://jsfiddle.net/tzgq6kva/
Is there a way to read all the cards that I have in Jira for a period?
My goal is to create a report with a number of cards that I have in REVIEW, the number of cards that I have in DONE and so on. I want to read the columns and know how many cards I have it.
It could be a script in JAVA or JAVASCRIPT.
Check out this post from the JIRA/Atlassian community: https://community.atlassian.com/t5/Jira-questions/REST-Client-get-all-issues-of-project/qaq-p/494826
Basically, you can use the REST endpoint /rest/api/2/search?jql=project="Your Project Key". This will return issues for whichever project you specify.
There is a wealth of documentation and knowledge on JIRA's API here
If the only information you need is a number of issues per status you can simply create a pie chart gadget for this. Because you want to display issues for a specific timeframe you will have to create a JQL filter first, then open existing or create a new dashboard (you need to be a dashboard administrator in order to add gadgets, you can become one by creating a new dashboard), then add a pie chart gadget, as a statistic type choose Status.
To find only the issues you are assigned to and that were updated within the specific time frame you need to create a search filter like:
assignee = currentUser() and updated > "2018/08/01"
this will find only the issues that are assigned to you and were updated after 2018/08/01.
The resulting chart will look like:
To import my crm data into Google analytics (GA), I linked the UserID of my users with ClientID in GA.
For this, I used the following code from GA documentation:
ga('set', 'userId', '432432');
Over time, the format of the User IDs on my website has changed - instead of the numbers, hashes are now used.
Can I now use the same code above, but only with new identifiers of my users, to send UserIDs то GA without damage current analytics?
In short, can I override the current User IDs in GA so that one user is not identified by the GA system as two different people?
You can't overwrite the historical data already processed by Google Analytics, only those of the current day.
You could apply the new algorithm only to new users of the crm, from a given id on, leaving the same encoding (numbers) for the previous ones (users already processed by Analytics).
If you have a mapping table between the new and old ids there is a solution.
You need to take out the data from GA - historically. (You can use the paid service from Scitylana for this - you get data in BigQuery or in S3)
Then you need a copy of the new_id old_id mappings table in the database where you put the exported data from Scitylana.
Since you can no longer rely on the ga:userType variable (new/returning). You need to create a query that calculates it again using the consolidated new ids.
This can all be set up in a flow that updates nightly.
But you need to analyze via SQL or use a dashboard tool like Power BI, Data Studio, Tableau etc.
Since the data from Scitylana is hit-level you can calculate everything correct, no need to worry about double aggregations etc.
(I work at Scitylana)
I'm switching from PayPal to Stripe so I can keep the checkout system entirely on my own sales site. While I have an intermediate understanding of PHP and API interactions, I'm so jaded from using PayPal for 3 years I can't figure out how the flow works for Stripe. Their documentation is excellent, it's more "Dictionary" like and not actual examples.
I'm looking to sell Subscription payments from my own site. You create the HTML, include the Stripe.js bit, but what's the process itself? As in, "index.php submits the checkout form, which notifies Stripe, which sends a ping back to charge.php..." etc, that sort of thing.
Where does the customer creation go, and how does it get attached to a CC charge?
Where does the confirmation from Stripe go?
Where does my price checking PHP go?
I've emailed Stripe, and while they're friendly enough they more or less just told me to go online to their documentation, which I've already spent hours in and still don't get it.
I know I'm being dumb - the tutorials online all seem to focus on Stripe Checkout, which is the popup that I don't want, not the custom HTML form.
Thanks in advance guys. :)
There are a number of different ways you can set it up. Here's how we do it in our application.
When the user enters CC information, you use the Stripe.js API on the client to submit the CC to Stripe, and it returns a token. The callback removes the CC data from your form, puts the token in a hidden field in the form, and submits the form to the server.
If you want to save the customer's CC information so they don't have to re-enter it every time, you then use the stripe-php API to create a \Stripe\Customer object for this CC, sending the token as the card parameter. This will return a customer ID, you can save this in your user database for future reuse.
To charge the card, you create a \Stripe\Charge object, with this customer ID in the customer field. The response from this indicates that the charge was successful; if there's a problem it will throw an exception.
If you just want to do a one-time charge without saving the CC permanently, you could just go straight to creating the \Stripe\Charge object, and use the token as the source field.
If you want to allow customers to have multiple saved cards, you create the \Stripe\Customer object the first time, and when they add a new card you retrieve their customer object, add the new token to the source array, and update it. Then on future charges you can specify both the customer and source fields. In this case, the source field should be the card ID of one of their saved cards.
You would presumably do your own validation of the form, and calculate the price, before calling the Stripe API from the PHP script.
Stripe do have a section with examples and sort of step by step guides for this, don't know if you found it - its separate to the API documentation and I didn't see it first time round. [https://stripe.com/docs/subscriptions/quickstart][1] [1]: https://stripe.com/docs/subscriptions/quickstart
For this to make sense, you will need to install their client library for PHP (or whatever you're using) and be familiar with PHP forms.
To answer your questions:
Where does the customer creation go, and how does it get attached to a
CC charge?
This is done using the functions from their library, see link above. The customer creation is sort of separate from the charge. You will need to store the customer ID in your database to charge them later.
Where does the confirmation from Stripe go?
This is returned in the response from the api call.
Where does my price checking PHP go?
Not sure what you mean by this. Presumably you work out the price to charge them first with your code, you can then just give this to stripe as an amount.
Hope this helps.
I'm trying to figure out how to get the location of someone filling out a web form on my site. I just want to get it down to a state level for US and Country for international(although state or equivalent is fine international too). I just don't want the user to have to select from a super long list or fill out a field. So ideally something like a hidden field that could have javascript or php pass the info to it.
Any ideas?
You can try; http://www.w3schools.com/html/html5_geolocation.asp
And using Google API:
http://maps.googleapis.com/maps/api/staticmap?zoom=10&size=400x400&maptype=roadmap&markers=color:red%7Ccolor:red%7Clabel:C%7Cxx.xxxxxxx,xx.xxxxxxx&sensor=false
Using PHP or Javascript to replace the "xx.xxxxxxx"'s will give you a map of the users location.
You can probably use Google API to determine the users State, etc - as you mentioned. But I don't think you will be baby fed on this one.
You could try to figure out their location using their IP address. However, this is far from reliable. Unfortunately, if you need this data to be accurate, you're going to have to get them to give you their location.