JSON Profile Data
Making a JSON request is likely to follow these steps (assuming you have an email address already):
- Create a valid email hash
- Build the URL to request a profile page
.jsonto that URL to indicate that you want the results in JSON format
Once you have done the above, you should end up with a URL that looks something like this:
When you request that URL (you can do it in your browser) you should get a JSON document containing all open profile data. We use Portable Contacts to format our profile data whereever possible, so see the PoCo spec for more details on the structure of the response.
callback to the URL, then that will be wrapped around the resulting JSON object and thus executed when the data is fully loaded.
A request with a callback (to execute an 'alert') would look something like this:
This makes it easy to load a Gravatar profile dynamically and immediately act on the contents of that profile by just loading a script URL like this:
Drop the following code into a new file and save it with
.html as the extension, then load it in a browser. It will load my profile and set the
title of the document to my name.
- The JSONView plugin for Firefox makes JSON much easier to read.
- Links (a href) within the "Description" field are automatically modified to include
rel="nofollow"on profile pages, but the raw profile data does not have this change applied.
- As with all profile data formats, profile requests will only resolve for the hash of the primary address on an account. Users may have multiple addresses on a single account, so while a Gravatar image request may return a result, a profile request for the same hash may not.