rams_ttype.php

00001 <?php
00002 # Sample that explains you how to use the PHP RawsClient lib to communicate with the RAMS 'traffic-type' resource
00003 #
00004 # Copyright (C) 2010 rambla.be
00005 
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #      http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 require_once '../RawsClient/Raws/Rams.php';
00019 
00020 # Provide your own credentials here
00021 define('BASE', 'http://rams.mon01.rambla.be/');
00022 define('USER', 'XXX');
00023 define('PWD', 'XXX');
00024 
00025 try {
00026   $rams = new Rams(USER, PWD, BASE);
00027 
00028   echo "->Retrieving a RAMS Traffic Type Feed:\n";
00029   # get the feed
00030   $feed = $rams->getTrafficTypeFeed();
00031   foreach ($feed as $entry) {
00032     # Retrieve the value of the params child elements
00033     echo "Name: " . $entry->content->params->name->text . "\n";
00034     echo "Product: " . $entry->content->params->product->text . "\n";
00035     echo "Description: " . $entry->content->params->description->text . "\n";
00036     echo "\n";
00037   }
00038 
00039   
00040 }
00041 catch(Zend_Gdata_App_Exception $e) {
00042     # Report the exception to the user
00043     echo "\nCaught exception: " . get_class($e) . "\n";
00044     echo "Message: " . $e->getMessage() . "\n";
00045     # get the HTTP status code
00046     echo "HTTP Status Code: " . $e->getResponse()->getStatus() . "\n";
00047     echo "Response Body with exception details: " . $e->getResponse()->getBody() . "\n";
00048     # get the raws:error elements
00049     $rawsResponse = Raws::parseRawsResponse($e->getResponse());
00050     echo "Raws Code: " . $rawsResponse->getCode() . "\n";
00051     echo "Raws Message: " . $rawsResponse->getMsg() . "\n";
00052     $reasons = $rawsResponse->getReasons();
00053     foreach ($reasons as $reason) {
00054       echo "Raws Reason: " . $reason . "\n";
00055     }
00056     $details = $rawsResponse->getDetails();
00057     foreach ($details as $key => $value) {
00058       echo "Raws Detail: " . $key . " -> " . $value . "\n";
00059     }
00060 }
00061 catch (Zend_Exception $e) {
00062     echo "Caught exception: " . get_class($e) . "\n";
00063     echo "Message: " . $e->getMessage() . "\n";
00064 }

Generated on Mon Mar 28 15:03:20 2011 for RawsClient PHP by  doxygen 1.5.3