So i have a project where i use 'google/apis/analytics_v3' to make some requests and get some data, the thing is that i need a view_id to do that.
#service.get_ga_data(VIEW_ID, #start_date, #end_date, 'ga:users').totals_for_all_results
the thing is that, on the new version of the analytics we don't have the view_id and i cannot find a way in ruby to do the same that this does.
Someone knows how to migrate to GA4 in ruby on rails, i can't find much documentation. We are talking about server side requests to google.
Thanks in advance to someone who can help me
I went over the GA4 configs trying to find the view_id, i've seen that this will be deprecated.
I've tried find other gems to make the requests and the authentication
Went to the github of the gem to check for updates.
Couldn't find a way
The 'google/apis/analytics_v3' library is for use with Universal analytics and requires a view id.
You need to use the Google analytics data api to access google analytics ga4 accounts.
require "google/analytics/data"
Google::Analytics::Data.configure do |config|
config.credentials = "path/to/keyfile.json"
end
client = Google::Analytics::Data.analytics_data
Related
I was following this tutorial, https://towardsdatascience.com/how-to-download-twitter-friends-or-followers-for-free-b9d5ac23812, which was written in 2021. It should've worked fine, however, they have to 'fix' the things that just work.
Specifically, running this line
for fid in Cursor(api.followers_ids, screen_name=screen_name, count=5000).items():
ids.append(fid)
gives the error:
"tweepy.error.TweepError: [{'message': 'You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve', 'code': 453}]"
I could have pulled the data in five minutes. Now debugging this already cost one hour+ because they just break the things that work. Is there anyway to make this old code snippet work? The application to use API 1.1 takes weeks, and I don't have time to watch their bad documents of how to migrate from API 1.1 to 2.0 and then the documents of migrating from Tweepy 3.9.0 to 4.0.0. Five minutes' task would just become half a day. Thanks in advance for any help.
First of all, have you at least tried to apply for the Elevated access?
It can take some time, it's true, but it can also be instantaneous.
The other solution would be to use the Twitter API V2.
You don't need any tutorial, just read the documentation:
Here for the authentication ;
Here for the retrieval of the followers ;
Here for the pagination.
And you should get something like that:
import tweepy
client = tweepy.Client("Bearer Token here")
paginator = tweepy.Paginator(
client.get_users_followers,
id=..., # ID only, no screename
max_results=1000
).flatten()
for follower in paginator:
print(follower.id)
Finally, even if I understand your frustration (and developing Twitter applications can be very frustrating), I think that you should try to keep it out your SO questions. Good luck!
I'm trying to debug a "too many queries" error I'm getting in my rails app. It appears that the rate limit is being surpassed. I'm trying to locate where the app is providing a Google Geocoding service API key but I don't see it anywhere. I understand that you can optionally create a geokit config file in config/initializers/geokit_config.rb and provide an API key there. However, this project has no such geokit config file.
Does the geokit library use a default Google Geocoding service API key that is hardcoded in the library if there is no geokit_config.rb file present in the app? Stated another way, is it completely optional to provide a Google geocoding API key to use the geokit library with its included google geocoding service functionality?
Thanks for any help.
I'm the maintainer of geokit. Yes, you can use it without a key, though I personally feel it would be unwise to do so in production.
But it is nice for "trying" the gem, though you'll hit your limit very quickly (you might even get that error straight away depending on how google limit, e.g. by IP)
See the README to easily set this:
# See https://developers.google.com/maps/documentation/geocoding/#api_key
Geokit::Geocoders::GoogleGeocoder.api_key = ''
I am looking to implement First Click Free in my rails application. Google has this information on how to verify a if a googlebot is viewing your site here.
I have been searching to see if there is anything existing for Rails to do this but I have been unable to find anything. So firstly, does anyone know of anything? If not, could anyone point me in the right direction of how to go about implementing what they have suggested in that page about how to verify?
Also, in that solution, it has to do a lookup every time to try and detect google, that seems like its going to be a big performance hit if I have to do it every page load? I could cache the IP if it has been verified in the past but Google have stated that their IP's change so at some point it may no longer belong to them. Although it probably doesn't happen regularly so it may not be that big of an issue.
Many thanks!!
Check out the browser gem: https://github.com/fnando/browser
What I'd do is use the
browser.bot?
method to check if your site is being accessed by a bot or not. If you care about the Googlebot specifically, you could check if
browser.name
includes googlebot. Keep in mind that this gem just checks the user agent sent by the client's browser, which could of course be spoofed. Sounds like that isn't a huge concern for your purposes.
I've built a Ruby gem for that recently, it's called "legitbot".
You may learn if a Web request comes from a supported bot using
bot = Legitbot.bot(userAgent, ip)
"legitbot" does this looking into User-agent and searching for a bot signature, i.e. how bots identify themselves. This doesn't guarantee that the Web request IP really comes from e.g. Googlebot. To make sure it is, call
bot.detected_as # => "Google"
bot.valid? # => true
bot.fake? # => false
Supported bots are Googlebot, Yandex bots, Bing, Baidu, DuckDuckGo.
I just got an API key for a database I wish to access and want to start building my Rails app. However I dont know where to begin with the API key. Specifically I want to use the brewerydb data and I am building an app where users can find the closest brewery to their location. Can anyone tell me how to get started? I am new to Rails and have never used an API before. I don't know where to begin. What file should I put it in, etc... I know I should probably update the GEMFILE, where else?
Thanks!
Check the documentation for the API. That's all I can say. (well... not really: )
Most API's rely on REST or SOAP, which is basically making HTTP request to certain URI's. An example may be
http://api.somewebsite.com/beers.json
Which would return, for instance, a JSON array of certain beers and their properties.
Furthermore, more often than not, you can test API's (that do not require certain HTTP headers for authentication, which makes it harder) by manually constructing the URI's and opening them in your browser. This way, you can verify that your request is okay before you try it in your Rails application an cannot figure out why it's not working.
You should use the 'figaro' gem https://github.com/laserlemon/figaro
It creates a "application.yml" file in which you can add your API key.
Can any one help me to send sms using way2sms api by means of rails application.
Thanks
I have created a free open source SMS API called AlfaSMS API for way2sms,160by2.com,fullonsms. It is available in many programming languages like PHP,VB,C++,c#,Python etc.You can download it from http://www.alfredfrancis.in/alfasms-api/
I have developed an API that anyone can use. Check it out here.
You can use the web page I created or you can use the API. For example, your application can directly forward the request to:
http://ubaid.tk/sms/sms.aspx?uid=99999xxxxx&pwd=12345&msg=YOUR_SMS_MESSAGE&phone=9996669990&provider=way2sms
The different providers are way2sms, fullonsms, smsinside and tezsms.
Works 100%, all the time. :)
Edit: As of 2014, the service is stopped since it violates the TOS of most of these providers.
Cheers.
There is a ruby gem that I wrote based on Ubaid's API. You can find it here.
You can use it in any ruby or rails project as long as you are running a version of ruby >= 1.9.
require 'chagol'
texter = Chagol::SmsSender("9876543210","password","way2sms")
texter.send("9968154700", "Chagol Rocks")
Disclaimer, I am the author of this gem.