Você está na página 1de 7

e o - ta g ging

API Documentation g
A riment
expe Labs
from HP

hpgloe.com
In this document we describe the General Protocol
API for the HP Gloe service, a All APIs support JSONP, that is a callback HTTP GET parameter may be passed and the
result is then the string:
geo-tagging experiment from HP
Labs. The goal of this document is callback(json data);
to promote mashup services and
All operations may be called using HTTP GET with the format:
customized clients to be written
on top of Gloe and to allow http://www.hpgloe.com/json/operation/?param1=val1&param2=val2…
syndication of Gloe content.
The API also allows native clients Authentication
to be built for platforms that Gloe Most operations can be called without requiring authentication. There are two ways
of authenticating a user, with Facebook Connect, and with the native Gloe
currently does not support, such authentication protocol.
as a Firefox extension or iPhone
app. For a general description of To initiate a Facebook Connect login a browser should be opened with the URL:

Gloe see the separate HP Gloe http://www.hpgloe.com/json/mobilefblogin/


Overview document.
This will direct the user to the Facebook login page and set the cookies in the browser that are
required to link the users’ Facebook account with a corresponding Gloe account. For first time
For further information and logins a new Gloe account will be created dynamically.
technical support, please contact
gloecontact@hp.com. For more information about Facebook connect see http://developers.facebook.com/connect.
php. To login to a native Gloe account (without requiring a Facebook identity) the user must
first register an account using the register operation (see below) to obtain a Gloe nickname
and recommendation key. Authenticated requests must contain a timestamp parameter with
the current time using the time format %Y%m%d%H%M%S, e.g. 20091231235959. The
request must also contain a user parameter with the nickname of a registered Gloe user. The
parameter values must then be signed in alphabetical order using the HMAC/SHA1 algorithm
(See e.g., the Authentication section in http://docs.amazonwebservices.com/AWSEC2/
latest/DeveloperGuide/index.html?using-query-api.html for implementation details) with the
recommendation key. Note Gloe uses the AWS signature version 1 scheme. The difference
to v2 are: we don’t include the parameter names in the data to sign, we order by parameter
name alphabetically, and we only support SHA1. The signature must then be passed in a
signature parameter. All operations apart from the friend management operations support
both authenticated and anonymous users. Anonymous users should not pass any signature
parameter. Anonymous users are identified by their IP and will have a much stricter quota for
making recommendations.

HP GLOE • API DOCUMENTATION • 2


operations Parameters that need to be part of the signature apart from user
name and timestamp are marked in pink.

Name parameters description Output format comment

getrec lat – latitude (required) Return recommendations JSON array of 10-tuple with If filter is not all
based on a geolocation and elements [<rank>,<url>, authentication is required.
lon – longitude (required) various filters. Defaults are <title>,<thumburl>,
radius: 10 miles and hits: <sample>,<tags>,<latitude>,
radius – search radius
10 recommendations and <longitude>, <clicks>,
hits – # result items no filters. <distance>] thumburl, sample
and tags are all deprecated,
tag – channel name latitude and longitude are
averages. All text is in
filter – me, all, friends unicode compatible URL
encoding.
ref – url reference (used
by notes attached to Web
pages)

q – string to search for in title


or url

rec lat – latitude (required) Recommend and geotag JSON object with If the url parameter is used it
Web sites or comments/ attribute message set to is a regular recommendation
lon – longitude (required) notes on Web sites. RECOMMENDATION_ for an existing site. If the
RECORDED if all went well notes parameter is used the
url – url to recommend
and attribute quote set to url of the recommendation
(required)
the remaining quota. will be created dynamically
tags – channel to and hosted on the gloe
recommend on server. If click=true the
recommendation does
ref – url that this not count towards to
recommendation is in recommendation quota and
reference to it is not taken into account
when ranking Web sites.
notes – used instead of url to
create notes

title – title of
recommendation

click – true/false

HP GLOE • API DOCUMENTATION • 3


operations

Name parameters description Output format comment

register nickname – requested gloe Registers a new gloe JSON object with message An email will be sent to
user name (required) account. attribute set to REGISTRATION_ the provided address if
SUCCESS or error attribute registration succeeded.
email – email address of set to DUPLICATE_NAME_ The email will contain an
account (required) OR_EMAIL if nickname or activation link and a user
email already exists (should be id. The activation link must
done over https to obtain the be opened in a browser to
recommendation key on the activate the account. The
wire in the key attribute). nickname and the user id
must be used to sign requests
that require authentication.

friends action – remove/add (required) Adds or removes friends to JSON object with attribute Requires authentication.
filter on to a gloe account. message set to FRIENDS_
friends – space separated list UPDATED and friends set to new
of friends (space separated) list of friends
if all went well.

getrectag lat – latitude (required) Returns most popular tags in JSON array of 2-tuple with
a geolocation. elements [<rank>,<tag>].
lon – longitude (required)

radius – search radius


(required)

hits – # result items (required)

filter – arbitrary string to filter


channels on

level – 1/2/..., number of tag


hierarchies to search

HP GLOE • API DOCUMENTATION • 4


operations

Name parameters description Output format comment

info friends – true/false, return Returns current quota and JSON object with attribute Authentication required.
friends or not friends of an authenticated quota set to remaining quota
user. and attribute friends set to
current friends.

top lat – latitude (required) Get top contributors in a JSON object {“top”: [[“<id1>”, Names attribute provides
geolocation. <recs1>],...], “names”: human readable names for
lon – longitude (required) {“<userid1>”: {“LastName”: user ids if available.
“<last name 1>”, “FirstName”:
“<first name 1>”}...}}}

HP GLOE • API DOCUMENTATION • 5


examples

(URL encoding omitted for readability)

Example USE

http://www.hpgloe.com/json/getrec/?lat=37.23 Get all recommendations


4&lon=-122.234 for geolocation (37.234,-
122,234)

http://www.hpgloe.com/json/ Recommend http://www.


rec/?lat=37.234&lon=-122.234&url=http://www. hp.com in geolocation
hp.com&tags=hp (37.234,-122,234) on
channel hp

http://www.hpgloe.com/json/register/?nicknam Register new user with


e=tom&email=tom@example.com nickname tom and email
tom@example.com

http://www.hpgloe.com/json/friends/?action=a Add Bob as a friend to the


dd&friends=bob&user=tom&timestamp=2009123123 Tom account
59&signature=sdfawefawefwefwa

http://www.hpgloe.com/json/getrectag/?lat=37 Get list of most popular


.234&lon=-122.234 channels in geolocation
(37.234,-122,234)

http://www.hpgloe.com/json/info/?user=tom&ti Get quota and friend info


mestamp=20091231235959&signature=dfggergerdr for user Tom
gerger

http://www.hpgloe.com/json/ Get top contributors in


top/?lat=37.234&lon=-122.234 geolocation (37.234,-
122,234)

HP GLOE • API DOCUMENTATION • 6


errors Errors are returned inside a JSON object with attribute error. Eg.:

{“error”: “error string”}

ERROR ERROR STRING

User that tries to authenticate is not found USER_NOT_FOUND

Anonymous access is attempted to operation AUTHENTICATION_REQUIRED


that requires authentication

The signature in the request was not valid AUTHENTICATION_FAILURE

The client IP could not be determined CLIENT_IDENTIFICATION_FAILED

Quota exceeded, no more QUOTA_EXCEEDED


recommendations allowed

Location parameters missing NO_LOCATION

The channel name is not permitted INVALID_CHANNEL

The url is not permitted (must not be an INVALID_URL


I and must not be blacklisted)
IP

The note text is not permitted INVALID_NOTE

The nickname is not permitted INVALID_NICKNAME

The email is not permitted INVALID_EMAIL

The nickname or email already exists DUPLICATE_NAME_OR_EMAIL

The recommendation was not successful RECOMMENDATION_FAILED

To learn more about HP Labs, visit http://hpl.hp.com.

HP GLOE • API DOCUMENTATION • 7

Você também pode gostar