Objects with location, anyone figured it out? - facebook-graph-api

This statment is found in the graph api (https://developers.facebook.com/docs/reference/api/)
Objects with location. The following will return information about
objects that have location information attached. In addition, the
returned objects will be those in which you or your friend have been
tagged, or those objects that were created by you or your friends.
But it is not stated how to make this call, has anyone figured it out?
In order to get pure checkins the following is used: https://graph.facebook.com/search?type=checkin

But it is not stated how to make this call, has anyone figured it out?
Like any other Graph API call …? With a simple HTTP request, probably including an access token, or with the help of one of the SDKs, which take care of the more basic aspects of this for you.

If you do a search for location objects you need to include the point and radius for your search, see example below for a search over the center of Gothenburg with 1000 meter distance (max for distance is 50000 meters)
https://graph.facebook.com/search?type=location&center=57.708549,11.975098&distance=1000&access_token=xxx

Related

Find cities within a circle with Here.com API

I need to find the cities (municipality) in a circle around a point, the only way I found to do that is to search for "city-hall" (800-8100-0163). I use with curl from php to retrieve the json result.
https://browse.search.hereapi.com/v1/browse?at={$coords}&in=circle:{$coords};r={$raggio}&lang=it&categories=800-8100-0163&limit=100&apiKey=<apiKey>
but some cities are missing in the result even if there's a city-hall in there so I think it's the wrong way to do that.
So my question is: is there a better way to achieve what I need?
It seems your request should be other.
If you search in Places Category System then should be parameter cat=800-8100-0163 and parameter (category system) should be cs=pds
Then request will look like: https://places.ls.hereapi.com/places/v1/browse?in=42.2722%2C13.3917%3Br%3D180718&cat=800-8100-0163&size=100&cs=pds&Accept-Language=it-It%2Cit%3Bq%3D0.9%2Cru-RU%3Bq%3D0.8%2Cru%3Bq%3D0.7%2Cde-DE%3Bq%3D0.6%2Cde%3Bq%3D0.5&app_id=WvHj2YKdvDQaKq1ZWCwL&app_code=W-ENnB-UBLqwG7sEhqyLMQ

Correct REST API URL format for related objects

I'm designing a REST API where, amongst others, there are two objects.
Journey
Report
For each Journey there are many Reports enroute, and each Report has exactly one associated Journey.
A user might create a Journey using the API as follows...
POST /journey/
Then retrieve the details...
GET /journey/1226/
The first question is, if a user wanted to post an Report to their Journey, which is the 'correct' URL structure that the API should impose? This seems intuitive to me...
POST /journey/1226/report/
...or is this the case...
POST /report/
...whereby in the latter, the Journey ID is passed in the request body somewhere?
The second question is, how might one go about implementing the first case in a tool such as the Django REST framework?
Thanks!
The URL/URI structure is almost completely irrelevant. It is nice to be able to read it, or easily change or even guess it, but that is it. There is no "requirement" official or unwritten how they should look like.
The point is however, that you supply the URIs to your clients in your responses. Each GET will get you a representation that contains links to the next "states" that your client can reach. This means the server has full control over URI structure, the client usually has to only know the "start" or "homepage" URI, and that's it.
Here is an article which discusses this question, has some good points: http://www.ben-morris.com/hackable-uris-may-look-nice-but-they-dont-have-much-to-do-with-rest-and-hateoas/
Pass for the second question :) I didn't use that particular framework.

FaceBook Graph API: Search beyond immediate circle

Is it possible to search for users which are beyond my immediate circle using FB graph API?
If not, does having a paid subscription account help to overcome this hurdle?
I'm using following graph query but seems to be restricted within my circle:
https://graph.facebook.com/search?q=xx+yy&limit=5000&type=user&access_token=*
Also if I increase the offset using pagination in the next call, It will still returns the same set of user IDs. So not sure if I'm passing the parameters incorrectly or missing some other parameters.
Thanks for all your help in advance!
Not sure what you mean by your immediate circle in terms of Facebook but I assume you mean your friends. The Graph API allows you to search for all public objects (source) - this means every person (according to answers on this page since names are always publicly available - that's my understanding), not only people who you are friends with on Facebook.
Hence, when you're searching for "John" you should get everyone called John if you're using the Graph API correctly - make sure your access token is valid (you do not need any special permissions to search for people) and your syntax follows the example from here.
In order to test your query I suggest you use the Graph API Explorer before adding the query to your application code. It's a quick way to see if the error is in your query or elsewhere. For example, if you want to find everyone named John, use this link http://developers.facebook.com/tools/explorer?method=GET&path=search%3Fq%3DJohn%26type%3Duser. Just make sure to click Get access token on the right if you're using the Explorer for the first time, otherwise the query will return an error.

Graph API: Number of Comments for Posts Are Inconsistent Among Various API Calls

Hello Graph API experts,
When you call /[post_id , the result contains "comments" field which has "count" field that is supposed to have the total number of comments for this particular post.
Now, if you call /[post_id]/comments , you get the actual comment data, one by one.
The problem I am facing is that, when I compare the "comments.count" field's value and the number of all of the actual comment data returned, they are different.
What's even worse, if you then look at the same post on Facebook.com's Timeline where you can see the number of comments for that post (i.e. "view all * comments" link), this number is also different from the "comments.count" field value.
And this is not only happening to one post, but to many of them - I observe this tend to happen more to posts with more than 100 comments (I actually counted all the comments on Timeline, and it matched the number of the actual comment data returned from /[post_id]/comments API call).
Is this a normal API behaviour? Which number should I or would you trust if this is the way it is?
ok, when you looking some facebook comment counts on some timeline posts, you woulld see that count for ex. 16 comments, and when you try to count comments manually on the post you may see it's looking 15 comments, so where is it that missing comments ? is that a wrong count by facebook ? no not actually, it's because, some people changing profile privacies as like don't show my comments people who aren't my friends, or we haven't any mutual friends, etc. it's because you cannot get these privatized comments from graph api, but these comments aren't excluding in total count. So what's the solution, just be sure get all the data correctly what facebook provide you. And compare it, how many comments looking like missing, and show missing counts as private comments count in your application. I think is much better.
Welcome to the world of Facebook API programming. Yes, this is normal (but apparently not desired) API behavior. This is one of the inconsistencies we're faced with when programming around their API. CBroe is probably correct in his comment above, it is data inconsistencies between servers in their API cluster.
in addition to this there are problems with pagination, you can use the offset + limit parameters to say how much data you want and from where to take it, if you deal with number of posts, you can say offset=0 and limit=50 and it'll work, but then if you try offset=100 and limit=50 it might return empty data, but then try offset=100 and limit=100 and it'll return 100 posts.
the api is just buggy and full of inconsistencies which don't seem to have any way to solve them.
I think we got oversold on the opengraph, I don't think it's what facebook told us it would be and I'm starting to feel the burn from selling that to my boss and finding out that I perhaps can't deliver :(

I need a sunrise/sunset webservice api

Anyone know of a good webservice or api that I can use to get the sunrise/sunset times in bulk? Every thing I have found so far only gives a day at a time or has a limitation on what dates can be used.
http://sunrise-sunset.org/api
It's free to use. Just needs a credit link back to the website.
It's not a web service, but this SO question has links to algorithms, so you can create a table or your own web service with all the dates you need.
I recently found this JavaScript library that performs calculation based on date and lat/lon coordinates. It seems to be very precise.
Link: https://github.com/mourner/suncalc
It is also available as NodeJs package through npm.
NASA has the calculation in nicely laid out JS. View the source of this page:
http://www.esrl.noaa.gov/gmd/grad/solcalc/
NOTE: I'm not a lawyer but I believe the US Government cannot copyright anything, hold patents, etc. so one should be able to copy as use as one needs.
This is a nice and free sunrise and sunset times API: http://sunrise-sunset.org/api
PHP has built in functions to calculate sunrise/sunset:
http://php.net/manual/en/function.date-sunrise.php
http://php.net/manual/en/function.date-sunset.php
Weather underground has this:
wunderground astronomy feature
Keys are free and they have a pretty generous policy for volume. Been using their weather actuals and forecast json forecast for about year, couldn't be happier.
EarthTools comes up first on google here at webservices sunrise sunset
The NASA one is cool, but the US Naval Observatory has one (below) that could actually pass for an API. If you want to make it useful beyond its intended purpose:
inspect the http headers to find out what parameters are being sent
parse the hell out of the response
It was a fun exercise. You should be able to send a location (long/lat or City/State) along with a year to obtain a list of sunrise and sunset times for an entire year (and other data as well).
http://aa.usno.navy.mil/data/docs/RS_OneYear.php
Go to this website > https://www.esrl.noaa.gov/gmd/grad/solcalc/
1. Set your location
Select your location. You can zoom in to your location and move the pin manually.
2. Verify your Location and Date
Scroll down to the 'Location' under the map and verify your location.
The date is automatically taken, if not set it manually.
3. Get the details
Click the button 'Create Sunrise/Sunset Tables for the Year'.
4. Output in a Table
New window opens and all the details are displayed as table.
Thanks to #noctonura for the link.
Let's go to http://www.earthtools.org/webservices.htm
It's free web service that provides Timezone and Sun times from Latitude/Longitude location.
There is a way to calculate the sunrise/sunset without the need of an API. Its mostly based on location. Sorry I dont have much more info.
Home page
Query url
Url syntax:
http://sunpath.azurewebsites.net/api/values/LAT/LON/ALT/TIMEZONE
You must replace LAT, LON, ALT and TIMEZONE with your data
.
JSON result:
{"zenith":55.365660255995422,"azimuth180":25.434155784212443,"azimuth":205.43415578421244,"incidence":55.365660255995422,"suntransit":12.423540739046871,"sunrise":6.9577562375305817,"sunset":17.899687249200021,"time":"2016-02-23T13:49:31.3816733Z"}
Or you can access online version of SPA.c algorithm:
Online query for SPA algorithm
Output is not in JSON format, but you can specify multiple times and get multiple results:
Date,Time,Top. azimuth angle (westward from S),Topocentric sun declination,Topocentric sun right ascension,Top. elevation angle (uncorrected)
2/23/2016,0:00:00,168.224314,-10.130760,335.659091,-57.643946
2/23/2016,1:00:00,-164.161551,-10.115560,335.699290,-57.227919
2/23/2016,2:00:00,-140.171655,-10.100376,335.739465,-51.963801
2/23/2016,3:00:00,-122.026618,-10.085209,335.779585,-43.529014
2/23/2016,4:00:00,-108.202194,-10.070054,335.819621,-33.425695
2/23/2016,5:00:00,-96.857772,-10.054907,335.859549,-22.544581
2/23/2016,6:00:00,-86.694509,-10.039764,335.899355,-11.406096
2/23/2016,7:00:00,-76.801678,-10.024618,335.939030,-0.376624
2/23/2016,8:00:00,-66.440121,-10.009464,335.978575,10.203398
2/23/2016,9:00:00,-54.907983,-9.994297,336.017999,19.930206