Facebook Events appear on Google Map - facebook

is there a way I can make events on the standard Facebook events app appear on a custom Google Map I've created?
Any tips would be much appreciated.

Given you have the user_events permission, you can access the locations like so:
FB.api("/me/events", function(events) {
if(events.error)
console.error(events);
var map = "http://maps.googleapis.com/maps/api/staticmap?zoom=14&size=512x512&maptype=roadmap&sensor=false";
for(var i = 0; i < events.data.length; i++) {
var point = "&markers=color:blue%7Clabel:S%7C";
point += (events.data[i].venue.latitude + "," + events.data[i].venue.longitude);
map += point;
}
var img = document.createElement("IMG");
img.src = map;
document.body.appendChild(img);
});
I didn't test it, but this should be enough to show an example of how to access the API in the browser and render a map with it's information. This is using Google Maps static API.

I just created a python script, source here.
It queries the given facebook page and it's events and puts the data into a MySQL table. It also contains a Geo-cache library, which combines a local database with the Google Maps Geocoding API, so you can query the longitude and the latitude of the events very fast.

Related

SAPUI5 - Accessing Sub Account ID from within controller

I'm accessing a URI from my controller which at the moment is hardcoded to my current SAP Cloud Platform Sub-Account.
window.open("https://rsaactionplan-(subaccount).dispatcher.hana.ondemand.com/index.html#/actionplan/" + oBindingContext.JobId, "_system");
Rather than hard-code it, how can I access the current sub-account ID so I can dynamically setup the sub-account in the SAPUI5 controller?
You can get access to account related details using Tenant Context APIs.
Please check here for details https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/a8f2255658ba4cbfb3ec3ab0f928f360.html?q=TenantContext
Best Regards,
Saurav
My solution for both hybrid + web app.
following any oData Read......
var uriStr;
if (typeof sap.hybrid !== 'undefined') {
uriStr = oUserData.__metadata.uri;
}
else{
uriStr = window.location.href;
}
var split1 = uriStr.split("-"); // split by -
var secondSubString = split1[1]; // all characters AFTER the first -
var split2 = secondSubString.split("."); // split by .
self.subAccount = split2[0]; // all characters BEFORE the first .
Then use self.subAccount into the calling URI.

How to get active users of a specific page by Google analytics API?

I use rt:activeUsers metric to get active users on website for realtime data.
I want to get active users in real time for a specific page (path or url), not the whole website. Is there a way to implement it? I went through API Explorer but gain no success.
For anybody else looking for this below is an example of how I accomplished this in javascript.
I started with the sample at: https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/
That sample uses a extension to the embed api to get active users: active-users.js
I didn't know where to get that active-users.js file so I just used the developer tools in Chrome and grabbed it that way. Saved it locally and linked to it in my page. If anyone knows a official location to get that please comment below. Thx.
If you look at the source to that file, I modifed the pollActiveUsers function to add a filters parameter like so:
pollActiveUsers_: function () {
var t = this.get(),
i = 1e3 * (t.pollingInterval || 5);
if (isNaN(i) || i < 5e3)
throw new Error("Frequency must be 5 seconds or more.");
this.polling_ = !0,
gapi.client.analytics.data.realtime.get({
ids: t.ids,
metrics: "rt:activeUsers",
filters: t.filters
}).then(function (t) {
var e = t.result,
s = e.totalResults ? +e.rows[0][0] : 0,
n = this.activeUsers;
this.emit("success", {
activeUsers: this.activeUsers
}),
s != n && (this.activeUsers = s, this.onChange_(s - n)),
1 == this.polling_ && (this.timeout_ = setTimeout(this.pollActiveUsers_.bind(this), i))
}
.bind(this))
},
Now in my page javascript I can call it like so:
var activeUsers = new gapi.analytics.ext.ActiveUsers({
container: 'active-users-container',
pollingInterval: 5,
filters: "rt:pagePath==/somepath/somepage/",
ids: "ga:<yourviewid>"
});
Hope that helps somebody.
While the Real-time API is very limited it does allow you to use filters. Filters are a kind of where clause.
The real-time documentation is also very limited but you can look at the documentation for filters on the core reporting API it works the same
filters=ga:browser%3D~%5EFirefox
I think you should check out the dimension rt:pagePath its probably what you are looking for.

Accessing Facebook data through the Facebook Graph API and restFB

When I access Facebook through the Graph API I get only very few entries. For instance if I access the Galaxy S4 fan page through the Graph API I see only four entries:
https://graph.facebook.com/412437702197294/comments/
if I access it through restFB I only get 2:
FacebookClient publicOnlyFacebookClient = new DefaultFacebookClient();
Page page = publicOnlyFacebookClient.fetchObject("GalaxySFour", Page.class);
JsonObject galaxySFourID = publicOnlyFacebookClient.fetchObject("GalaxySFOUR", JsonObject.class);
JsonObject galaxySFour = publicOnlyFacebookClient.fetchObject(galaxySFourID.getString("cover_id") + "/comments", JsonObject.class);
Vector<String> comments = new Vector<String>();
for(int i = 0; i < galaxySFour.length(); i++) {
comments.add("Message: " + galaxySFour.getJsonArray("data").getJsonObject(i).getString("created_time") + ": " + galaxySFour.getJsonArray("data").getJsonObject(i).getString("message"));
}
I'm aware that I cannot get all data, but I didn't expect to get so little. Is there anyway to get more data?
Access via this link : http://facebook.com/412437702197294,
there are only 4 comments. So, https://graph.facebook.com/412437702197294/comments/ return 4 comments is right.
By default, when retrieving data via Facebook Graph API, you only get 20 results.
You can use limit to get more data, such as:
http://facebook.com/412437702197294?limit=500
The maximum limit is 5000.

Bing Maps Ajax API - get location from address

I'm using Microsoft.Maps API (AJAX control v. 7).
I want to display pin for an address.
When I use:
var loc = new Microsoft.Maps.Location(47.592, -122.332);
var pOptions = {icon: 'img/ICN_Bullet_Blue_25x38.gif', text: '1'};
var pin = new Microsoft.Maps.Pushpin(loc, pOptions);
It's working fine. How can I get latitude and longitude from address, so I will later use it for pin location ?
Bing Maps includes geocoding support (finding location by addresses).
You have two options for this:
Use the REST api directly. http://msdn.microsoft.com/en-us/library/ff701714.aspx
In that page you can find plenty of examples. You make a REST HTTP request and obtain a JSON that includes the geocoded coordinates.
Use the Microsoft.Maps.Search module. http://msdn.microsoft.com/en-us/library/hh868060.aspx
You just load the module and then do something like:
var search = new Microsoft.Maps.Search.SearchManager(map);
search.geocode({where:"some address...", count:10, callback:geocodeCallback});
and then, in your callback just handle the results:
function geocodeCallback(geocodeResult, userData)
{
var location = geocodeResult.results[0].location;
}

Tag photo Graph API / REST API

I'm doing a FB app with the Graph API in Flash. I've got everything working which consists in uploading some images created by the user in the app. The only part that I'm missing is how to tag these photos as with the Graph API it is not possible.
So I was wondering if it's possible to call a method of the REST API even though I'm using the Graph API.
Any suggestion on how to deal with that?
Thanks
This question was asked a long time ago but no answers for when I was looking so here's the answer. (Hint: it's all about the formatting of the JSON string within the param object being passed to the Graph API)
function postPhoto( e:MouseEvent ) : void
{
var bitmapData:BitmapData = new BitmapData( 600, 600 );
bitmapData.draw( someSprite );
var bitmap:Bitmap = new Bitmap( bitmapData );
var params:Object = { image:bitmap, message:'Message', fileName:'file-name', tags:'[{"tag_uid":"12345678","x":"0","y":"0"}]' };
FacebookDesktop.api( 'me/photos', photoPostComplete, params );
}
function photoPostComplete( result:Object, fail:Object ) : void
{
//do callback type of stuff
}