Getting started with Riya


The Riya API provides a set of methods that you can use to integrate Riya's image searching technology into your own application. The API uses the standard HTTP GET and HTTP POST requests in the Representational State Transfer (REST) style.


Please note that the riya.photos.upload.UploadPhoto method requires the POST method. All other methods in the Riya API require the GET method.


Before you can use the Riya API, you'll need an API Key. To use the methods in the API, you'll need to pass two required parameters, method and api_key, in addtion to any parameters that the specific method requires. Most methods require authentication. You must pass the user_name and auth_token parameters to any method that requires authentication. The method parameter must contain the name of the method you're calling. The api_key parameter must contain your API key.


Riya stores the images you upload in two sizes. The thumbnail size is used to display a list of images. Thumbnails are 160 by 120 pixels in size. The screen resolution image is used to display the image when the user selects it and is 800 by 600 pixels in size.


All the PHP code examples in this document require the riyaapi.class.php.html file, which you can download here.


To use a Riya API method, send an HTTP GET or HTTP POST request to the API endpoint, http://www.riya.com/rest. Append the method's parameters to the URL, as in the following example.


The riya.auth.GetToken method requires the user_name and password parameters, in addition to the mandatory parameters method and api_key. The complete URL that your web application passes in the HTTP GET request is:


http://www.riya.com/rest?api_key=b049a05a3d153c8d&user_name=sajan@riya.com&password =123456&method=riya.auth.GetToken

The ? character after http://www.riya.com/rest indicates the beginning of your request. The parameter names are separated from the parameter values by the = character. Indicate the beginning of each parameter name-value pair after the first with the & character.


When the method you call returns successfully, the HTTP request returns an XML file with the results. You can parse this file and use the information in your application, typically to format the resulting HTML page or to pass to other Riya API methods. In the example above, the riya.auth.GetToken method returns an authentication token in the following format:


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <auth>
    <token>a2b0d79e7bec3f06</token>
    <user fullname="Paul Echeverri"/>
  </auth>
</rsp>



After parsing the XML, you can pass the token as a parameter to other Riya API calls.

 

Top

User Authentication Method


Most of the methods in the Riya API require an authentication token. The only method in the API that does not require a token is the public search method riya.photos.search.SearchPublic. In general, it's a good idea to get an authentication token as the very first step in any Riya web application.


To get an authentication token, pass your user's username and password to riya.com with the riya.auth.GetToken method, as in the following example.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  
  $response = $r->getAuthToken(password);
  
  if ( $response !== false ) {
     
    // Output the token
    echo $response;
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '
'; echo 'Error Message: ' . $r->getErrorMessage() . '
'; } ?>

After your application parses the token from the XML response, your user can perform any of the tasks that the API makes possible. We'll discuss these tasks in the following sections.

Top

Image Management Methods


It's likely that the first thing you'll want to do is upload images to your account. Images must be in the JPEG file format, and the minimum resolution is 100 by 100 pixels. You can use the Riya Uploader, or you can upload single images manually using riya.photos.upload.UploadPhoto. Note that, while all of the other methods in this API use the GET method, the riya.photos.upload.UploadPhoto method uses POST.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.upload.UploadPhoto', array(
                                'photo'  => './test.gif',     // Replace this with the photo path
                                'access' => 'private-access', // public-access/private-access
                             )); 
  
  if ( $response !== false ) {
    
    // Parse photo data from XML
    $photo = RiyaApi::parseAttributes($response->photo);
    
    // Output success message with ID
    echo 'Photo uploaded successfully. ID: ' . $photo['id'];
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '
'; echo 'Error Message: ' . $r->getErrorMessage() . '
'; } ?>

The riya.photos.upload.UploadPhoto method requires the access, user_name, and api_key parameters. The access parameter can take on two values, private-access and public-access. When this method completes successfully, it returns a unique ID string for the image.

<image_id="b74799e325de61ad"/>

After you've uploaded an image, you can mark it as Public or Private. A Private image is not visible on public searches. You can search through all of your own Private images. To mark an image as Private or Public, call the riya.photos.ChangePhotoPermission method. This method requires the image_id and access parameters. Any user can make any image Private, but only the image's owner can change a Private image to Public.

<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.ChangePhotoPermission', array(
                                'image_id' => image ID,
                                'access'   => access level,
                             )); 
  
  if ( $response !== false ) {
    
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
   

If you want to delete a photo from your account, call the riya.photos.DeletePhoto method. This method requires the image_id parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.DeletePhoto', array(
                                'image_id' => image ID
                             )); 
  
  if ( $response !== false ) {
    
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '
'; echo 'Error Message: ' . $r->getErrorMessage() . '
'; } ?>

 

Top



Facial Detection Methods


When you upload an image, riya.com automatically performs facial recognition on the image, drawing a rectangle around each face that it detects. If the face matches a face that you've already trained Riya to recognize, Riya automatically enters the name for the recognized face. You can enter names for any new faces that Riya hasn't recognized, or correct the names for faces that Riya may have identified incorrectly.


You can call the riya.photos.faces.IdentifyFace method to alter the name that Riya assigns to a face. This method requires the image_id, face_id, and full_name parameters. The image_id parameter uniquely identifies the image that contains the face you want to rename. The face_id parameter uniquely identifies the specific face in the image. The full_name parameter is the name you want to assign to that face.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.faces.IdentifyFace', array(
                                'image_id'  => image ID,
                                'face_id'   => face ID,
                                'full_name' => full name
                             )); 
  
  if ( $response !== false ) {
     
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '
'; echo 'Error Message: ' . $r->getErrorMessage() . '
'; } ?>

If there's a face in an uploaded picture that Riya didn't detect as a face, you can use the riya.photos.faces.AddFace method to mark the area of the image where the face is. This method requires the image_id, x, y, w, and h parameters. The x and y parameters define the pixel coordinates of the top left corner of the rectangle. The w parameter specifies the width of the rectangle in pixels. The h parameter specifies the height of the rectangle in pixels.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.faces.AddFace', array(
                                'image_id' => image ID,
                                'x'        => x-coordinate,
                                'y'        => y-coordinate,
                                'w'        => width,
                                'h'        => height,
                             )); 
  
  if ( $response !== false ) {
     
    // Parse face data from XML
    $face = RiyaApi::parseAttributes($response->face);
    
    // Output success message with ID
    echo 'Face added successfully. ID: ' . $face['id'];
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '
'; echo 'Error Message: ' . $r->getErrorMessage() . '
'; } ?>

In this method, both the X and Y coordinates and the height and width dimensions are relative to the top-left corner of the thumbnail (160x120) image. When this method completes successfully, it returns a unique ID for the face.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <face id="05adc61619169a5e"/>

</rsp>

Riya may incorrectly identify an area in your image as a face. You can call the riya.photos.faces.RemoveFace method to remove these misidentified areas. This method requires the image_id and face_id parameters.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.faces.RemoveFace', array(
                                'image_id' => image ID,
                                'face_id'  => face ID,
                             )); 
  
  if ( $response !== false ) {
    
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '
'; echo 'Error Message: ' . $r->getErrorMessage() . '
'; } ?>

To get a list of all the faces that Riya can identify in a given image, call the riya.photos.faces.GetFaceList method. This method requires the image_id parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.faces.GetFaceList', array(
                                'image_id' => image_id,
                             )); 

  if ( $response !== false ) {
    
    // Loop through all faces
    foreach ($response->faces->face as $face) {
      // Parse face properties
      $properties = RiyaApi::parseAttributes($face);
      // Output entity
      echo 'Tag: ' . $properties['tag'] . ' (ID: ' . $properties['id'] . ')';
      echo '<br />';
      echo 'Location: ' . $properties['x'] . ', ' . $properties['y'];
      echo '<br />';
      echo 'Dimensions: ' . $properties['w'] . ', ' . $properties['h'];
      echo '<br /><br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

In this method, both the X and Y coordinates and the height and width dimensions are relative to the top-left corner of the thumbnail (160x120) image. When this method completes successfully, it returns a list of the unique face IDs that are present in the image.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <faces>

    <face id="c08f36c6ce8d7b43" tag="Emma Frost" x="197.71179" y="151.2931" w="46.532753" h="46.551723"/>
    <face id="d418d5f9da9ce281" tag="Spider Jerusalem" x="310.81223" y="125.43104" w="43.30131" h="43.318966"/>
    <face id="89d98f87de68afa2" tag="Zatanna" x="425.85153" y="160.34483" w="43.947598" h="43.96552"/>
    <face id="2254e0c5bcc2f443" tag="Captain America" x="1107.3899" y="1000.00006" w="501.69495" h="500.00003"/>
    <face id="6a677d8b3d8938e9" tag="Who Is This?" x="1107.3899" y="1000.00006" w="501.69495" h="500.00003"/>
    <face id="ab58d046292d0b57" tag="Who Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
    <face id="05adc61619169a5e" tag="Who Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
  </faces>
</rsp>

 

Top



Overlay Management Methods


Overlays are rectangular areas in an image that you define. Riya automatically performs text recognition inside an overlay and adds any detected text to the overlay's label, in addition to the automatic text recognition that Riya performs when you upload an image. You can search for overlays by label just as you can search for faces by name. You can use overlays to call out areas of interest in your image that aren't faces, and define their labels in any way you want.


To create a new overlay in an image, call the riya.photos.overlays.AddOverlay method. This method requires the image_id, x, y, w, and h parameters. The x and y parameters define the pixel coordinates of the top left corner of the rectangle. The w parameter specifies the width of the rectangle in pixels. The h parameter specifies the height of the rectangle in pixels. In this method, both the X and Y coordinates and the height and width dimensions are relative to the top-left corner of the thumbnail (160x120) image.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.overlays.AddOverlay', array(
                                'image_id' => image ID,
                                'x'        => x-coordinate,
                                'y'        => y-coordinate,
                                'w'        => width,
                                'h'        => height,
                             )); 
  
  if ( $response !== false ) {
     
    // Parse overlay data from XML
    $overlay = RiyaApi::parseAttributes($response->overlay);
    
    // Output success message with ID
    echo 'Overlay added successfully. ID: ' . $overlay['id'];
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns a unique identifier for the new overlay.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <overlay id="d5fd6ce09974124d"/>

</rsp>

To remove an overlay, call the riya.photos.overlays.RemoveOverlay method. This method requires the image_id and overlay_id parameters.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.overlays.RemoveOverlay', array(
                                'image_id'   => image ID,
                                'overlay_id' => overlay ID,
                             )); 
  
  if ( $response !== false ) {
    
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     


To change the label for an overlay, call the riya.photos.overlays.EditOverlay method. This method requires the image_id, overlay_id, and tag parameters. The tag parameter contains the value that you want to assign to the overlay's label.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.overlays.EditOverlay', array(
                                'image_id'   => image ID,
                                'overlay_id' => overlay ID,
                                'tag'        => tag contents
                             )); 
  
  if ( $response !== false ) {
     
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     


To list all of the overlays in an image, call the riya.photos.overlays.GetOverlayList method. This method requires the image_id parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.overlays.GetOverlayList', array(
                                'image_id' => image ID,
                             )); 
                             
  if ( $response !== false ) {
    
    // Loop through all overlays
    foreach ($response->overlays->overlay as $overlay) {
      // Parse overlay properties
      $properties = RiyaApi::parseAttributes($overlay);
      // Output entity
      echo 'Tag: ' . $properties['tag'] . ' (ID: ' . $properties['id'] . ')';
      echo '<br />';
      echo 'Location: ' . $properties['x'] . ', ' . $properties['y'];
      echo '<br />';
      echo 'Dimensions: ' . $properties['w'] . ', ' . $properties['h'];
      echo '<br /><br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns a list of the overlays in the image.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <overlays>

    <overlay id="8b70102a243c2b34" tag="What Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
    <overlay id="2b5ab3bfb0c20085" tag="What Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
    <overlay id="6fb4c2fea7803265" tag="What Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
    <overlay id="9ca89c2d7da00620" tag="What Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
    <overlay id="d5fd6ce09974124d" tag="What Is This?" x="605.69495" y="500.00003" w="50.169495" h="50.000004"/>
  </overlays>
</rsp>
     

 

Top



Comment and Tag Management


Comments and tags are text labels that anyone can append to an image on Riya.com. Comments and tags can only be deleted by the image's owner. You can search for a specific tag to find images, but you cannot search through comments.


To add a tag to an image, call the riya.photos.tags.AddTag method. This method requires the image_id and tag parameters. The tag parameter contains the value that you want to assign to the image.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.tags.AddTag', array(
                                'image_id' => image ID,
                                'tag'      => tag contents,
                             )); 
  
  if ( $response !== false ) {
    
    // Parse tag data from XML
    $tag = RiyaApi::parseAttributes($response->tag);
    
    // Output success message with ID
    echo 'Tag added successfully. ID: ' . $tag['id'];
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     


To list all the tags on an image, call the riya.photos.tags.GetTagList method. This method requires the image_id parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.tags.GetTagList', array(
                                'image_id' => image ID,
                             )); 
                             
  if ( $response !== false ) {
     
    // Loop through all tags
    foreach ($response->tags->tag as $tag) {
      // Parse tag properties
      $properties = RiyaApi::parseAttributes($tag);
      // Output entity
      echo $properties['tag'];
      echo ' (type: ' . $properties['type'] .', id: ' . $properties['id'] . ')';
      echo '<br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML list of the tags in the image.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <tags>

    <tag type="exifMake" tag=""/>
    <tag type="exifModel" tag=""/>
    <tag type="exifOrientation" tag=""/>
    <tag type="exifDateTime" tag="2005:05:31 17:20:43"/>
    <tag type="exifImageWidth" tag="916"/>
    <tag type="exifImageHeight" tag="928"/>
    <tag type="exifVersion" tag=""/>
    <tag type="userTag" tag="notobwdsktp9qh.jpg"/>
    <tag id="5c39a5d78eea0a2e" type="userTag" tag="old"/>

    <tag id="86b47dd9b74e482d" type="userTag" tag="old"/>
    <tag id="3c65e37709f722a8" type="userTag" tag="old"/>
    <tag id="42f628a534744fae" type="userTag" tag="old"/>
    <tag id="816f56add718d9a5" type="userTag" tag="old"/>
    <tag id="5eac022a791389b6" type="userTag" tag="old"/>
  </tags>
</rsp>
     

To remove a tag from an image, call the riya.photos.tags.RemoveTag method. This method requires the image_id and tag_id parameters.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.tags.RemoveTag', array(
                                'image_id' => image ID,
                                'tag_id'   => tag ID,
                             )); 
  
  if ( $response !== false ) {
    
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     


To add a comment to an image, call the riya.photos.comments.AddComment method. This method requires the image_id and comment parameters. The comment parameter has the value of the comment that you want to add to the image.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.comments.AddComment', array(
                                'image_id' => image ID,
                                'comment'  => comment text,
                             )); 
  
  if ( $response !== false ) {
     
    // Parse comment data from XML
    $comment = RiyaApi::parseAttributes($response->comment);
    
    // Output success message with ID
    echo 'Comment added successfully. ID: ' . $comment['id'];
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML identifier for the comment.


<rsp>?xml version="1.0" encoding="UTF-8"?> <rsp stat="ok">
<comment id="b06d247972f33b8a"/> </rsp>


To list all the comments on an image, call the riya.photos.comments.GetCommentList method. This method requires the image_id parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.comments.GetCommentList', array(
                                'image_id' => image ID,
                             )); 
                             
  if ( $response !== false ) {
     
    echo 'Comments: ';    
    echo '<hr />';
     
    // Loop through all comments
    foreach ($response->comments->comment as $comment) {
      // Parse comment properties
      $properties = RiyaApi::parseAttributes($comment);
      // Output entity
      echo '<img src="' . $properties['thumbnail'] . '" alt="Comment ID: ' . $properties['id']. '" />';
      echo '<br />';
      echo $properties['author'] . ' says: <i>' . $properties['comment'] . '</i>';
      echo '<hr />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML list of the comments in the image.


<rsp><?xml version="1.0" encoding="UTF-8"?> <rsp stat="ok"> <auth> <token>0934ddf7b009c3ff</token> <user fullname="Paul Echeverri"/> </auth> </rsp> XML END! XML START! <?xml version="1.0" encoding="UTF-8"?> <rsp stat="ok"> <comments> <comment id="9af2a6c1150fd8dd" thumbnail="http://www.riya.com/fileServer?p=dd48011c134266d24625e0dfd87617e08a7c32b8.jpg_face_thumbnail1" comment="Great shot!" author="Axel Brass"/> </comments> </rsp>


To remove a comment from an image, call the riya.photos.comments.RemoveComment method. This method requires the image_id and comment_id parameters.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.comments.RemoveComment', array(
                                'image_id'   => image ID,
                                'comment_id' => comment ID,
                             )); 
  
  if ( $response !== false ) {
    
    // Dumps the object to screen
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

 

Top



Contact Management


Riya stores the names of any faces you've identified in your photoset in an address book. A Contact is an entry in your address book. The address book holds names and email addresses. You can retrieve the list of all your contacts with the riya.contacts.GetContactList method.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.contacts.GetContactList');
  
  if ( $response !== false ) {
     
    // Loop through the contact list
    foreach ($response->contacts->contact as $contact) {
      // Parse contact properties
      $properties = RiyaApi::parseAttributes($contact);
      // Output contact
      echo '<a href="mailto:' . $properties['email'] . '">' . $properties['full_name'] . '</a> ';
      echo isset($properties['id']) && !empty($properties['id']) ? '(ID: ' . $properties['id'] . ')' : '';
      echo '<br />';
    } 
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML list of your contacts.


<?xml version="1.0" encoding="UTF-8"?> <rsp stat="ok"> <contacts> <contact full_name="Alice Liddell" email=""/> <contact full_name="Betsy Braddock" email=""/> <contact full_name="Black Widow" email=""/> <contact full_name="Cammy White" email=""/> <contact full_name="Captain America" email=""/> <contact full_name="Chun-Li" email=""/> <contact full_name="David Filippi" email=""/> <contact full_name="Dizzy Cordova" email=""/> <contact full_name="Doc Brass" email=""/> <contact full_name="Drywall" email=""/> <contact full_name="Emma Frost" email=""/> <contact full_name="Harley Quinn" email=""/> <contact full_name="Ingrid Bergman" email=""/> <contact full_name="Jean Grey" email=""/> <contact full_name="Kara Zor-El" email=""/> <contact full_name="Kevin Matchstick" email=""/> <contact full_name="Kevin Sack" email=""/> <contact full_name="Lyndon Johnson" email=""/> <contact full_name="Mai Shiranui" email=""/> <contact full_name="Mitchell Hundred" email=""/> <contact full_name="Morrigan" email=""/> <contact full_name="Petra" email=""/> <contact full_name="Robin" email=""/> <contact full_name="Spider Jerusalem" email=""/> <contact full_name="Venom - Guilty Gear" email=""/> <contact full_name="Zatanna" email=""/> </contacts> </rsp>


To get a list of all the faces in your photoset that are associated with a particular name, use the riya.contacts.GetFaceShots method. This method requires the full_name parameter. This method returns an XML list of the face thumbnails matching the name that you specify in the full_name parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.contacts.GetFaceShots', array(
                                'full_name' => contact name // Replace this name
                             )); 
  
  if ( $response !== false ) {
    
    $contact = RiyaApi::parseAttributes($response->contact);
    
    echo 'Full Name: ' . $contact['full_name'];
    echo '<br />';
    echo 'E-mail: ' . $contact['email'];
    echo '<br />';
    
    $face = RiyaApi::parseAttributes($response->contact->face);
    
    echo '<img src="' . $face['thumbnail'] . '" alt="" />';
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

 

Top



Album Management


When you upload images to Riya with the Uploader, the Uploader automatically assigns your images to albums based on the pathnames where the image files are located. You can also specify an album for an image when you upload it by using the riya.photos.upload.UploadPhoto method. The riya.albums.GetAlbums method shows all the albums for a given user.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.albums.GetAlbums');
  
  if ( $response !== false ) {
     
    // Loop through all albums
    foreach ($response->albums->album as $album) {
      // Parse album properties
      $properties = RiyaApi::parseAttributes($album);
      // Output entity
      echo '<img src="' . $properties['thumbnail'] . '" alt="' . $properties['id'] . '" />';
      echo '<br />';
      echo 'Album Name: ' . $properties['name'];
      echo '<br /><br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

Each album is displayed with a link to a representative image for that album. The representative image is the first image in that image set. This method also returns the album's name and unique ID.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <albums>
    <album id="ec84dd6b620c9d8e" name="0524200" 
	thumbnail="http://www.riya.com//fileServer?p=b8bed4046e534b23e4bf2a13cca614e2dad904ad.jpg_thumbnail"/>
    <album id="f37cce0ec82107ed" name="images" 
	thumbnail="http://www.riya.com//fileServer?p=4a8d9f8b2ae586fea399a0d5e451475399697580.jpg_thumbnail"/>
    <album id="9e46a2faee3f33a3" name="deskies" 
	thumbnail="http://www.riya.com//fileServer?p=e850d9d5fb1239691507802ee232cddfa2cb5c54.jpg_thumbnail"/>
    <album id="a20dc2824799772c" name="Ami's Bday 2005" 
	thumbnail="http://www.riya.com//fileServer?p=5d96367977914a4c5e6bebb51e0eacddf61b4b46.jpg_thumbnail"/>
    <album id="8118e7d48e4bd7ca" name="FamilyPix" 
	thumbnail="http://www.riya.com//fileServer?p=19dbe21f310b6f050f709e5e2018f832a4342b79.jpg_thumbnail"/>
  </albums>
</rsp>


To show all the photos in a given album, call the riya.albums.GetPhotosInAlbum method. This method requires the album_id parameter.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.albums.GetPhotosInAlbum', array(
                                'album_id' => album ID,
                             )); 
                             
  if ( $response !== false ) {
     
    echo 'Click on a photo to enlarge.';
    echo '<br /><br />';
    
    // Loop through all photos in the album
    foreach ($response->album->photo as $photo) {
      // Parse hoto properties
      $properties = RiyaApi::parseAttributes($photo);
      // Output entity      
      echo '<img src="' . $properties['thumbnail'] . '" alt="' . $properties['id'] . '" 
	  onclick="this.src=\'' . $properties['screenres'] . '\';" />';
      echo '<br /><br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML list of the image IDs for each image in the album, along with links to the image's thumbnailed and screen resolution versions.


<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <album id="ec84dd6b620c9d8e">

    <photo id="b8bed4046e534b23e4bf2a13cca614e2dad904ad" 
	thumbnail="http://www.riya.com/fileServer?p=b8bed4046e534b23e4bf2a13cca614e2dad904ad.jpg_thumbnail"
	screenres="http://www.riya.com/fileServer?p=b8bed4046e534b23e4bf2a13cca614e2dad904ad.jpg_screenres"/>
    <photo id="4fcd9a4766228b50c464b8a8322f49a638763cb3" 
	thumbnail="http://www.riya.com/fileServer?p=4fcd9a4766228b50c464b8a8322f49a638763cb3.jpg_thumbnail"
	screenres="http://www.riya.com/fileServer?p=4fcd9a4766228b50c464b8a8322f49a638763cb3.jpg_screenres"/>
  </album>
</rsp>
     

 

Top



Searches


The riya.photos.search.SearchPublic method searches through all of the images on riya.com whose permission is set to 'Public'. This is the only method in the Riya API that does not require authentication. This method takes several optional parameters:


person
Riya will try to match this parameter in a face's full_name attribute.
place
Riya will try to match this parameter in an image's tags.
text
Riya will try to match this parameter in an image's text overlays.
album
Riya will try to match this parameter in an album's name attribute
daterange
Riya will find images with dates in the specified range. The range must be in the format mm/dd/yyyy/hhmmss-mm/dd/yyyy/hhmmss.
date
Riya will find images whose date matches the specified date. The date must be in the format mm/dd/yyyy/hhmmss.
tags
Riya will try to match this parameter in an image's tags.

This method also takes three optional formatting parameters:


page
This parameter specifies the page number. The default value is 1.
per_page
This parameter specifies the number of returned images per page. The default value is 1. The maximum value is 50.
sort
This parameter specifies the sort order. The sort order can be date and time order or Riya ranking order. To specify date and time ordering, the value of the sort parameter must be date-time. To specify Riya ranking order, the value of the sort parameter must be riya-rank.
<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  
  $response = $r->callMethod('riya.photos.search.SearchPublic', array(
                                'person' => person name
                             ));
  
  if ( $response !== false ) {
     
    echo 'Click on a photo to enlarge.';
    echo '<br /><br />';
    
    // Loop through all photos
    foreach ($response->photos->photo as $photo) {
      // Parse photo properties
      $properties = RiyaApi::parseAttributes($photo);
      // Output entity
      echo '<img src="' . $properties['thumbnail'] . '" alt="' . $properties['id'] . '" 
	  onclick="this.src=\'' . $properties['screenres'] . '\';" />';
      echo '<br /><br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML list of the image IDs for each image found by the search, along with links to the image's thumbnailed and screen resolution versions.


<photos>
<photo id="cca0ab9cde6d13192da1461d0c522b16715abf56" thumbnail="http://www.riya.com/fileServer?p=cca0ab9cde6d13192da1461d0c522b16715abf56.jpg_thumbnail" screenres="http://www.riya.com/fileServer?p=cca0ab9cde6d13192da1461d0c522b16715abf56.jpg_screenres"/>
<photo id="f4fe35c9ccf5447386e28396d0b838c7093f7a73" thumbnail="http://www.riya.com/fileServer?p=f4fe35c9ccf5447386e28396d0b838c7093f7a73.jpg_thumbnail" screenres="http://www.riya.com/fileServer?p=f4fe35c9ccf5447386e28396d0b838c7093f7a73.jpg_screenres"/>
<photo id="80ba504b19ddd007bdfbc337e253493b8e286c12" thumbnail="http://www.riya.com/fileServer?p=80ba504b19ddd007bdfbc337e253493b8e286c12.jpg_thumbnail" screenres="http://www.riya.com/fileServer?p=80ba504b19ddd007bdfbc337e253493b8e286c12.jpg_screenres"/>
</photos>

To restrict a search to the images in your own photo collection, use the riya.photos.search.Search method. This method requires one parameter:

bucket
This mandatory parameter specifies the 'bucket' to search. This parameter can take on three values:
my-photos
This value restricts the search to your own images.
my-friends-photos
This value restricts the search to the images of users in your Contacts.
my-public-photos
This value restricts the search to images marked as 'public'

This method takes several optional parameters:


person
Riya will try to match this parameter in a face's full_name attribute.
place
Riya will try to match this parameter in an image's tags.
text
Riya will try to match this parameter in an image's text overlays.
album
Riya will try to match this parameter in an album's name attribute
daterange
Riya will find images with dates in the specified range. The range must be in the format mm/dd/yyyy/hhmmss-mm/dd/yyyy/hhmmss.
date
Riya will find images whose date matches the specified date. The date must be in the format mm/dd/yyyy/hhmmss.
tags
Riya will try to match this parameter in an image's tags.

This method also takes three optional formatting parameters:


page
This parameter specifies [asked Dan]. The default value is 1.
per_page
This parameter specifies the number of returned images per page. The default value is 1. The maximum value is 50.
sort
This parameter specifies the sort order. The sort order can be date and time order or Riya ranking order. To specify date and time ordering, the value of the sort parameter must be date-time. To specify Riya ranking order, the value of the sort parameter must be riya-rank.


<?php

  require_once 'riyaapi.class.php'; 
  
  $r = new RiyaAPI();  
  
  $r->setApiKey(your API key);
  $r->setUsername(username);
  $r->setAuthToken($r->getAuthToken(password));
  
  $response = $r->callMethod('riya.photos.search.Search', array(
                                'person' => person name
                             ));
  
  if ( $response !== false ) {
     
    echo 'Click on a photo to enlarge.';
    echo '<br /><br />';
    
    // Loop through all photos
    foreach ($response->photos->photo as $photo) {
      // Parse photo properties
      $properties = RiyaApi::parseAttributes($photo);
      // Output entity
      echo '<img src="' . $properties['thumbnail'] . '" alt="' . $properties['id'] . '" 
	  onclick="this.src=\'' . $properties['screenres'] . '\';" />';
      echo '<br /><br />';
    }
    
  } else {
    
    echo 'Error Code: ' . $r->getErrorCode() . '<br />';
    echo 'Error Message: ' . $r->getErrorMessage() . '<br />';
    
  }

?>
     

This method returns an XML list of the image IDs for each image found by the search, along with links to the image's thumbnailed and screen resolution versions.


<photos>
<photo id="cca0ab9cde6d13192da1461d0c522b16715abf56" thumbnail="http://www.riya.com/fileServer?p=cca0ab9cde6d13192da1461d0c522b16715abf56.jpg_thumbnail" screenres="http://www.riya.com/fileServer?p=cca0ab9cde6d13192da1461d0c522b16715abf56.jpg_screenres"/>
<photo id="f4fe35c9ccf5447386e28396d0b838c7093f7a73" thumbnail="http://www.riya.com/fileServer?p=f4fe35c9ccf5447386e28396d0b838c7093f7a73.jpg_thumbnail" screenres="http://www.riya.com/fileServer?p=f4fe35c9ccf5447386e28396d0b838c7093f7a73.jpg_screenres"/>
<photo id="80ba504b19ddd007bdfbc337e253493b8e286c12" thumbnail="http://www.riya.com/fileServer?p=80ba504b19ddd007bdfbc337e253493b8e286c12.jpg_thumbnail" screenres="http://www.riya.com/fileServer?p=80ba504b19ddd007bdfbc337e253493b8e286c12.jpg_screenres"/>
</photos>

 

Top

 
About Riya | Take the Tour | Blog | CEO Blog | Support | API | Jobs
© 2005-2009 Riya™. All rights reserved. Terms of Use | Privacy Policy | DMCA
Total photos searched: 9,887,329
riya-beta-release-10-10.0.26