HCG Web Services Documentation
23 April 2012 • Version 1.0

Remote Tags for Recipes

These remote tags are designed to provide recipe information through a simple tag placed in a remote website.

NOTE: Remote Tags are a restricted service and are intended for use only in websites owned by The Hain Celestial Group. They are not for general use. Please contact Jim Applegate if you need to set up access to Remote Tags.

Base URL : http://rtags.hcgweb.net/{version}/recipes/

The current version is v1.

The HTTP Method used is POST.

Available Tags:

detail

Displays a recipe detail page.

The data must be submitted via the POST method.

URL Format

http://rtags.hcgweb.net/{version}/recipes/detail

Parameter Required Description Options and Samples
version Yes The version of the rTag that you are using. Indicated as part of the URL. v1
site-id Yes The alpha code used to identify which HCG site you want data from. gfch = Gluten Free Choices

See a complete list of codes.
recipe-code Yes The url-friendly alpha code used to identify the recipe. almond-banana-smoothies = Almond Banana Smoothie
tpl No The template name for the detail page.* detail
detail_search

Default: detail
action No If the template includes a search form:
The URL for the page where the form will be processed. This must be a page containing the search remote tag.
http://example.com/recipes/search
Default: /recipes/search.php
by-brand No If the template includes a search form:
Sort the product list by brand?
TRUE
Default: FALSE
server-level No The database server to use to pull the recipe data. stage
live
Default: live

*For security reasons, there is no mechanism for overriding templates directly from a remote server. Many modifications can be made using CSS, but if you need to make markup changes to a template, contact Jim Applegate to either modify the default template or add a new template to the list of options.

Example Pages

The example page below shows what the tag looks like in action.

Templates and CSS

The code

The code below shows how to place the remote tag into your website page using cURL and PHP. Other implementations are possible.

<?php
   $post_array = array();
   $post_vars = '';
   $ch = '';
   $output = '';
   $rtag_url = $server.'v1/recipes/detail';
   
   $include_search = (isset($_GET['srch'])) ? TRUE : FALSE;
   
   $config = array();
   $config['site-id'] = 'gfch';
   $config['recipe-code'] = (isset($_GET['code'])) ? $_GET['code'] : 'french-dream-toast';
   if ($include_search) {
      $config['tpl'] = 'detail_search';
      $config['action'] = '/docs/recipes/recipes-example-3.html';
      $config['by-brand'] = TRUE; 
   }
   else
   {
      $config['tpl'] = 'detail';
   }
   $config['server-level'] = 'stage';

   foreach ($config AS $key => $value)
      $post_array[] = $key.'='.$value;
   
   foreach ($_POST AS $key => $value)
      $post_array[] = $key.'='.$value;

   $post_vars = implode('&', $post_array);

   $ch = curl_init($rtag_url);
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_HEADER, 0);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $output = curl_exec($ch);
   curl_close($ch);
        
   echo $output;
?>

categoryList

Displays a list of recipes in the given category.

The data must be submitted via the POST method.

URL Format

http://rtags.hcgweb.net/{version}/recipes/categoryList

Parameter Required Description Options and Samples
version Yes The version of the rTag that you are using. Indicated as part of the URL. v1
site-id Yes The alpha code used to identify which HCG site you want data from. gfch = Gluten Free Choices

See a complete list of codes.
category-code Yes The url-friendly alpha code used to identify the category. main-meals = Main Meals
detail-url No The URL for the detail pages. There are two replacement variables that can be used in the URL so you can format any way you need to:
  • {RecipeCode} is the code indicating the recipe
  • {CategoryCode} is the code indicating the recipe category
    /recipes/detail.php?code={RecipeCode}
    Default: /recipes/detail.php?code={RecipeCode}
    tpl No The template name for the category list page.* detail
    Default: category_list
    server-level No The database server to use to pull the recipe data. stage
    live
    Default: live

    *For security reasons, there is no mechanism for overriding templates directly from a remote server. Many modifications can be made using CSS, but if you need to make markup changes to a template, contact Jim Applegate to either modify the default template or add a new template to the list of options.

    Example Pages

    The example page below shows what the tag looks like in action.

    Templates and CSS

    The code

    The code below shows how to place the remote tag into your website page using cURL and PHP. Other implementations are possible.

    <?php
       $post_array = array();
       $post_vars = '';
       $ch = '';
       $output = '';
       $rtag_url = $server.'v1/recipes/categoryList';
    
       $config = array();
       $config['site-id'] = 'gfch';
       $config['category-code'] = (isset($_GET['code'])) ? $_GET['code'] : 'main-meals';
       $config['detail-url'] = '/docs/recipes/recipes-example-1.html?code={RecipeCode}';
       $config['tpl'] = 'category_list';
       
       foreach ($config AS $key => $value)
          $post_array[] = $key.'='.$value;
    
       foreach ($_POST AS $key => $value)
          $post_array[] = $key.'='.$value;
    
       $post_vars = implode('&', $post_array);
       
       $ch = curl_init($rtag_url);
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt($ch, CURLOPT_HEADER, 0);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       $output = curl_exec($ch);
       if ($output == '')
       {
          echo curl_error($ch);
       }
       curl_close($ch);
    
       echo $output;
    ?>
    

    search

    Displays a recipe search page.

    The data must be submitted via the POST method.

    URL Format

    http://rtags.hcgweb.net/{version}/recipes/search

    Parameter Required Description Options and Samples
    version Yes The version of the rTag that you are using. Indicated as part of the URL. v1
    site-id Yes The alpha code used to identify which HCG site you want data from. gfch = Gluten Free Choices

    See a complete list of codes.
    detail-url No The URL for the detail pages. There is one replacement variables that can be used in the URL so you can format any way you need to:
    • {RecipeCode} is the code indicating the recipe
      /recipes/detail.php?code={RecipeCode}
      Default: /recipes/detail.php?code={RecipeCode}
      tpl No The template name for the search page.* search
      Default: search
      home-page No The URL for the recipe home page content.
      • The URL needs to be fully-qualified as it will be referenced from the rTag server. Any <img> tags will also need to have fully-qualified URLs.
      • The content of the HTML file should be an HTML snippet, and NOT a complete HTML page with <html>, <head>, or <body> tags. The content is inserted into the template directly and not through a iFrame.
      http://example.com/recipes/home.html
      Default: none
      action No The URL for the page where the form will be processed. This must be a page containing the search remote tag. http://example.com/recipes/search
      Default: /recipes/search.php
      by-brand No Sort the product list by brand? TRUE
      Default: FALSE
      server-level No The database server to use to pull the recipe data. stage
      live
      Default: live

      *For security reasons, there is no mechanism for overriding templates directly from a remote server. Many modifications can be made using CSS, but if you need to make markup changes to a template, contact Jim Applegate to either modify the default template or add a new template to the list of options.

      Example Pages

      The example page below shows what the tag looks like in action.

      Templates and CSS

      The code

      The code below shows how to place the remote tag into your website page using cURL and PHP. Other implementations are possible.

      <?php
         $post_array = array();
         $post_vars = '';
         $ch = '';
         $output = '';
         $rtag_url = $server.'v1/recipes/search';
      
         $config = array();
         $config['site-id'] = 'gfch';
         $config['detail-url'] = '/docs/recipes/recipes-example-1.html?srch=1%26code={RecipeCode}';
         $config['tpl'] = 'search';
         $config['home-page'] = $doc_server.'docs/recipes/recipe-home.html';
         $config['action'] = '/docs/recipes/recipes-example-3.html';
         $config['by-brand'] = TRUE;
         
         foreach ($config AS $key => $value)
            $post_array[] = $key.'='.$value;
      
         // Using $_GET and $_POST allows you to send search parameters via
         // the URL as well as by submitting the search form
         // e.g. http://example.com/?meal-type=44 (link to breakfasts)
         foreach ($_GET AS $key => $value)
            $post_array[] = $key.'='.$value;
      
         foreach ($_POST AS $key => $value)
            $post_array[] = $key.'='.$value;
      
         $post_vars = implode('&', $post_array);
         
         $ch = curl_init($rtag_url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($ch);
         if ($output == '')
         {
            echo curl_error($ch);
         }
         curl_close($ch);
      
         echo $output;
      ?>