ruby koala facebook graph geting public events - ruby

I want to get a list of events from a venues facebook page. There is code to configure koala at https://github.com/arsduo/koala. I setup a facebook App in Facebook and have app_id and app_secret but after much googleing cant work out where to get 'access_token = MY_TOKEN' or 'app_access_token = MY_APP_ACCESS_TOKEN'.
Ive looked at the Graph API Explorer (https://developers.facebook.com/tools/explorer) but cant seem to work out how to do it. For example one of the events pages is at https://www.facebook.com/pg/The-Old-England-186748738025516/events/?ref=page_internal.
Also example code on how to get the list would be great but the above world be a great start.

Found answer, it was very simple:
Koala.config.api_version = 'v2.10'
oauth = Koala::Facebook::OAuth.new 'my_id', 'my_secret'
graph = Koala::Facebook::API.new oauth.get_app_access_token
fb_events = graph.get_object( '186748738025516/events' )

Related

Youtube Api no result issue

I'm trying to use Youtube Api V3 to get documentaries videos, unfortunately I can't get any results for many searched keys.
Is there any advanced configuration I can use to get more results or is there any alternative API(s) ?
this is my query
https://www.googleapis.com/youtube/v3/search?part=snippet&q=alien&type=video&videoCategoryId=35
First and foremost make sure you have an API_KEY. Follow link for details, then go to developer console to get one.
Then your request URL should look like this.
var API_KEY = "your api key";
var channelID = "The channel id u wan to pull";
var result = 30 // Limit the number of videos
`https://www.googleapis.com/youtube/v3/search?key=${API_KEY}&channelId=${channelID}&part=snippet,id&order=date&maxResults=${result}`
With an API key, I also pulled 0 results for 'alien' in the Documentary category. Perhaps there aren't any.

Google api ruby client issue with the insert_calendar method

I am using the google code sample for the google calendar api. This code is supposed to make a new calendar using the google calendar api. I am not clear on how to get access to the insert_calendar method.
Does anybody know where did the client object come from in the results variable? What class does it come from?
calendar = Google::Apis::CalendarV3::Calendar.new(
summary: 'calendarSummary',
time_zone: 'America/Los_Angeles'
)
result = client.insert_calendar(calendar)
print result.id
I don't know how to make a new one of those. When I make a new object like:
client = Google::APIClient.new
and I call methods, on it. I do not find an insert_calendar method. Can some one tell me what object I would need to instantiate in order to have the insert_calendar method?
This is a simple question but I am having a huge problem finding out how to answer this on my own.
The docs page is here. It looks like it's an instance method of Google::Apis::CalendarV3::CalendarService.
Since the usage isn't particularly clear from this documentation, I went to the google-api-client source on Github and used the "search this repository" tool to find where insert_calendar is defined.
It's in this file.
From looking at the source & docs I can advise you try the following code (though I haven't verified this:
calendar = Google::Apis::CalendarV3::Calendar.new(
summary: 'calendarSummary',
time_zone: 'America/Los_Angeles'
)
Google::Apis::CalendarV3::CalendarService.new.insert_calendar(
calendar: calendar,
# other options can go here
)

how to get the fan page name of Facebook wall post?

I am reading the wall posts of fan pages under my FB account using C# SDK. I would like to know the page id of the wall post. Is there any property in C# SDK?
As people start to use the Graph objects more an more, the FQL seems to be fading. But FQL is not deprecated (at least not yet).
For a particular wall post you're reading via your C# SDK, simply FQL it:
SELECT source_id FROM stream WHERE post_id = {post_id}
For more information https://developers.facebook.com/docs/reference/fql/stream/
For information on how to make an FQL query run in the C# SDK, see:
http://blog.prabir.me/post/Facebook-CSharp-SDK-Making-Requests.aspx
But it's going to look something like this
var client = new FacebookClient(access_token);
// this is where you already grab your post, so you have post_id
var data = client.query("SELECT source_id FROM stream WHERE post_id =" + post_id);

framework and aprroach to get youtube insight data using ruby

I need to get user, channel & video insight data (views, ratings, subscribers etc) from youtube using ruby.
which tool/gem/framework to use:
I know this is asked before, but this is specific to my problem, I dont want to upload videos etc, most of the frameworks seem geared to this.
None of these seem to be a great fit to me, am I better off using httparty and rolling my own?
youtube-model - http://github.com/edgarjs/youtube-model/tree/master
youtube-g - http://github.com/tmm1/youtube-g
gdata on rails - http://code.google.com/apis/gdata/articles/gdata_on_rails.html
which api to use?
Should I use this api: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_insight.html
I need a list of videos before I can call this, also I need to figure out what channel the user has, ideally get insight data at the channel level, if not I can aggregate it.
Or are feeds: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_understanding_video_feeds.html
a better way to get this kind of data.
I spent some time working on this over the weekend. Youtube-Model seems to work the best:
Use example in youtube model to get authsub token
yt = YouTubeAccess.uploaded_by_user(token)
yt_videos = yt.videos
yt_videos.each{|video|
view_count = video.statistics.viewCount.to_i
favorite_count = video.statistics.favoriteCount.to_i
comment_count = video.comments.attributes['feedLink'].countHint.to_i
}
Not sure how to do channels, but this is a good start.

reading RSS returns different response on localhost

im trying to parse an rss feed on localhost, and it brings back the right results, but when i try to do that from another (preproduction server) and live, it returns a list of comments made by users on the hydrapinion website which is completely unrelated, have i been spoofed? how can i debug this? its just an rss feed and a simple LINQ code!
string bingurl = "http://www.bing.com/search?form=QBRE&filt=rf&qs=n&format=rss&count=10&q=+environment+(site:www.australianit.news.com.au)";
XDocument doc = XDocument.Load(bingurl);
IEnumerable<XElement> items = (from i in doc.Descendants("item")
orderby DateTime.Parse(i.Element("pubDate").Value) descending
select i).Take(10);
rpData.DataSource = items;
rpData.DataBind();
i tried a different combination, and i get no results at all! do u think the server settings have antyhing to do with retrieving rss results?
i found some decent guide for bing search, but as it turned out, bing doesnt bring decent resuls! and it appears to me it changes the results set according to where ur calling it from, i tried adding "loc:" to the rss, when called from code it returned different results than when called on bing website itself, i dont know the algorithm they are using but it is getting more obvious
the guide is here:
http://help.live.com/help.aspx?mkt=en-AU&project=a

Resources