XML example usage and response

Follow

Wodify_Bar_All.png

 

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. The World Wide Web Consortium's XML 1.0 Specification of 1998 and several other related specifications—all of them free open standards—define XML. The Wodify API can return either JSON or XML. 

 

In this article, we will cover:


Wodify REST API Endpoints

GET: https://app.wodify.com/API/WODs_v1.aspx?apikey=&location=&program=&date=&type=


Wodify's REST API can use response types XML or JSON.

The following article contains:

    • XML Example Usage
    • XML Response


XML Example


<!doctype HTML>
<html>
<head> </head>
<body>
  <?php  
    /*          
    * Quick function that makes a call to the Api/WODs_v1 endpoint, getting   WODS for a certain date.          
    * Parameters:          
    * $apikey = your api key          
    * $date = the date the wod took place, in YYYY/MM/DD format          
    * $location = the name of the location where the wod took place  
    * $program = the name of the program that the wod was a part of      
    * $isJSON = a boolean value indicating the response format          
    */        
   
    function GetWODs($apikey, $date, $location, $program, $isJSON){
      $data = array(                
        "apikey" => $apikey,                
        "date" => $date,                
        "location" => $location,                
        "program" => $program,                
        "type" => $isJSON ? "json" : "xml"            
      );              
      $ch = curl_init();              
      $url = sprintf("%s?%s", "https://app.wodify.com/API/WODs_v1.aspx",  
      http_build_query($data));              
      curl_setopt($ch, CURLOPT_URL, $url);            
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);            
      curl_setopt($ch, CURLOPT_HEADER, false);            
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');              
      $result = curl_exec($ch);            
      return $result;        
    }          
    $json = false; //XML        
    $response = GetWODs("np3g23grc9j81jlamjqmu1yo0", "11/20/2012", "Main", "Crossfit", $json);        
    print_r($response);        
    $xmlResponse = simplexml_load_string($response, NULL, TRUE);             $xmlWod = $xmlResponse->APIWod->WodHeader;  
  ?>
  <div>
    <h1>Sample RESTful with XML</h1>            
    <h1>
      <?php echo $xmlWod->Name;  ?>
    </h1>            
    <h2>
      <?php echo $xmlWod->Date;  ?>
    </h2>            
    <h3>Components:</h3>            
    <ul>                
      <?php                
         $xmlWodComponents = $xmlResponse->APIWod->Components;                      foreach ($xmlWodComponents->children() as $key => $value){
             echo "<li><pre>".$value->Description."</pre></li>";                 }  
      ?>            
    </ul>              
    <h3>Announcements:</h3>            
    <ul>                
      <?php                
        $xmlWodAnnouncements = $xmlResponse->APIWod->Announcements;
        foreach ($xmlWodAnnouncements->children() as $key => $value){
         echo "<li><pre>".$value->Message."</pre></li>";                         }
      ?>            
    </ul>        
  </div>
</body>
</html>

 

XML Response


This XML file does not appear to have any style information associated with it. The document tree is shown below.  

<RecordList>
  <APIWod>
    <WodHeader>
      <Id>24977</Id>
      <Date>2013-04-13</Date>
      <ShouldPublish>False</ShouldPublish>
      <PublishDateTime/>
      <Name>WOD</Name>
      <Comments/>
      <OwnershipLevelId>3</OwnershipLevelId>
      <UserId>19330</UserId>
      <ProgramId>5</ProgramId>
      <BlogPostId/>
      <IsPostUpdateRequired>True</IsPostUpdateRequired>
      <IsPostedToFacebook>False</IsPostedToFacebook>
      <HasBeenSaved>True</HasBeenSaved>
      <CreatedBy>19330</CreatedBy>
      <CreatedOn>2013-04-12T15:46:58</CreatedOn>
      <UpdatedBy>19330</UpdatedBy>
      <UpdatedOn>2013-04-12T16:23:16</UpdatedOn>
      <IsActive>True</IsActive>
    </WodHeader>
    <CreatedDate>2013-04-12</CreatedDate>
    <UpdatedDate>04/12/2013 16:23:16</UpdatedDate>
    <Location>
      <Id>5</Id>
      <Name>Main</Name>
      <StreetAddress1/>
      <StreetAddress2/>
      <City/>
      <StateId>0</StateId>
      <ZipCode/>
      <CountryId>0</CountryId>
      <Province/>
      <CreatedBy>17597</CreatedBy>
      <CreatedOn>2000-01-01</CreatedOn>
      <UpdatedBy>0</UpdatedBy>
      <UpdatedOn/>
      <IsActive>True</IsActive>
    </Location>
    <Program>
      <Id>5</Id>
      <Name>Crossfit</Name>
      <Description>Crossfit</Description>
      <Color/>
      <PublishExternally>True</PublishExternally>
      <CreatedBy>17597</CreatedBy>
      <CreatedOn>2000-01-01</CreatedOn>
      <UpdatedBy>0</UpdatedBy>
      <UpdatedOn/>
      <Is_Active>True</Is_Active>
    </Program>
    <Announcements></Announcements>
    <Components>
      <Component>
        <Id>7087</Id>
        <ComponentTypeName>Metcon</ComponentTypeName>
        <OwnershipLevelName>Global</OwnershipLevelName>
        <UserName/>
        <Name>Del</Name>
        <Description> For Time: 25 Burpees 400m run with a 20# medicine ball 25 Weighted pull-ups with 20# dumbbell 400m run with a 20# medicine ball 25 Handstand push-ups 400m run with a 20# medicine ball 25 Chest-to-bar pull-ups 400m run with a 20# medicine ball 25 Burpees </Description>
        <IsBenchmark>True</IsBenchmark>
        <HasBeenSaved>True</HasBeenSaved>
        <IsNewComponentEmailSent>False</IsNewComponentEmailSent>
        <AllowRxPlus>False</AllowRxPlus>
        <Rounds>0</Rounds>
        <Comments/>
        <Reps/>
        <PerformanceResultTypeName>Time</PerformanceResultTypeName>
      </Component>
      <Component>
        <Id>7089</Id>
        <ComponentTypeName>Metcon</ComponentTypeName>
        <OwnershipLevelName>Global</OwnershipLevelName>
        <UserName/>
        <Name>Diane</Name>
        <Description> 21-15-9 Deadlifts, 225# / 155# Handstand Push-ups </Description>
        <IsBenchmark>True</IsBenchmark>
        <HasBeenSaved>True</HasBeenSaved>
        <IsNewComponentEmailSent>False</IsNewComponentEmailSent>
        <AllowRxPlus>False</AllowRxPlus>
        <Rounds>0</Rounds>
        <Comments/>
        <Reps/>
        <PerformanceResultTypeName>Time</PerformanceResultTypeName>
      </Component>
      <Component>
        <Id>7097</Id>
        <ComponentTypeName>Metcon</ComponentTypeName>
        <OwnershipLevelName>Global</OwnershipLevelName>
        <UserName/>
        <Name>Fran</Name>
        <Description>21-15-9 Thrusters, 95# / 65# Pull-ups</Description>
        <IsBenchmark>True</IsBenchmark>
        <HasBeenSaved>True</HasBeenSaved>
        <IsNewComponentEmailSent>False</IsNewComponentEmailSent>
        <AllowRxPlus>False</AllowRxPlus>
        <Rounds>0</Rounds>
        <Comments/>
        <Reps/>
        <PerformanceResultTypeName>Time</PerformanceResultTypeName>
      </Component>
      <Component>
        <Id>7097</Id>
        <ComponentTypeName>Metcon</ComponentTypeName>
        <OwnershipLevelName>Global</OwnershipLevelName>
        <UserName/>
        <Name>Fran</Name>
        <Description>21-15-9 Thrusters, 95# / 65# Pull-ups</Description>
        <IsBenchmark>True</IsBenchmark>
        <HasBeenSaved>True</HasBeenSaved>
        <IsNewComponentEmailSent>False</IsNewComponentEmailSent>
        <AllowRxPlus>False</AllowRxPlus>
        <Rounds>0</Rounds>
        <Comments/>
        <RepScheme/>
        <PerformanceResultTypeName>Time</PerformanceResultTypeName>
      </Component>
    </Components>
  </APIWod>
</RecordList>

 

If you need any additional assistance with XML usage, feel free to reach out to us at support@wodify.com or via Priority Live Chat in your admin account (Promote only).

Comments

Check the current status of our products

View status