XML Profile Data
XML is a universal, structured data-encoding format, which is accessible via most programming languages. All open profile data may be accessed very easily using a simple XML format.
Making an XML 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
.xmlto that URL to indicate that you want the results in XML 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 an XML 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.
The XML data format does not support any additional options
This example (written in PHP 5.2+, and assuming you can
file_get_contents() and use SimpleXML) just loads up my profile in XML, queries my name via XPath and then outputs it:
<?php $str = file_get_contents( 'http://www.gravatar.com/205e460b479e2e5b48aec07710c08d50.xml' ); $xml = simplexml_load_string( $str ); $names = $xml->xpath( '//entry/displayName' ); if ( is_array( $names ) && isset( $names ) ) echo (string) $names; ?>
- Some fields within a profile may contain line breaks and other characters which are encoded in the XML output. Be sure to decode any characters before using the data.
- 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.