Advertisement
Guest User

php html

a guest
Sep 1st, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.99 KB | None | 0 0
  1. try {
  2.  
  3.     if ($_POST) {
  4.         switch ($_GET['list']) {
  5.  
  6.             case 1:
  7.                 //getProps
  8.                 $newsmanID = $_POST["UserID"];
  9.                 $api = $_POST["apiKey"];
  10.                 $listId = $_POST["listId"];
  11.  
  12.                 $client = new Newsman_Client($newsmanID, $api);
  13.  
  14.                 $ret = $client->list->getProps(
  15.                     $listId
  16.                 );
  17.  
  18.                 if (!is_array($ret)) {
  19.                     // handle error here
  20.                     die("Error on method list.getProps");
  21.                 }
  22.  
  23.                 print "<pre>";
  24.                 print_r($ret);
  25.                 print "</pre>";
  26.  
  27.                 break;
  28.             case 2:
  29.                 try {
  30.                     $newsmanID = $_POST["UserID"];
  31.                     $api = $_POST["apiKey"];
  32.  
  33.                     $listId = $_POST["listId"];
  34.  
  35.                     $client = new Newsman_Client($newsmanID, $api);
  36.  
  37.                     $ret = $client->list->getProps(
  38.                         $listId
  39.                     );
  40.  
  41.                     print "<pre>";
  42.                     print_r($ret);
  43.                     print "</pre>";
  44.  
  45.                     if (($_POST["propName"] != '') && ($_POST["newPropName"] != '')) {
  46.                         $ret = $client->list->updateProps(
  47.                             $listId,
  48.                             array($_POST["propName"] => $_POST["newPropName"])
  49.                         );
  50.  
  51.                         $ret = $client->list->getProps(
  52.                             $listId
  53.                         );
  54.                         echo 'Updated...';
  55.                         print "<pre>";
  56.                         print_r($ret);
  57.                         print "</pre>";
  58.                     }
  59.                 } catch (Exception $ex) {
  60.                     echo 'Update props method error. Make sure you introduced your data correctly.' . $ex;
  61.                 }
  62.                 break;
  63.         }
  64.     }
  65. }
  66.  
  67. catch (Exception $e) {
  68.     print $e;
  69. }
  70.  
  71. ?>
  72.  
  73.     <form id="apiForm" method="post">
  74.         <!-- getProps -->
  75.         <?php if(isset($_GET['list']) && $_GET['list'] == '1'): ?>
  76.             <div class="form-group">
  77.                 <div>
  78.                     <label class="desc">Returns a hash array with the properties of a list</label>
  79.                 </div>
  80.                 <label for="apiKey"> Api Key </label>
  81.                 <input type="text" name="apiKey" class="form-control" id="apiKey" placeholder="Api Key">
  82.                 <label for="listId"> List Id </label>
  83.                 <input type="text" name="listId" class="form-control" id="listId" placeholder="List Id">
  84.                 <label for="userID"> User ID </label>
  85.                 <input type="text" name="UserID" class="form-control" id="userID" placeholder="User Id">
  86.             </div>
  87.             <div class="divSpacing">
  88.             <button type="submit" name="seeProperties" class="btn btn-primary"> See properties</button>
  89.                 </div>
  90.             <!-- getProps -->
  91.         <?php elseif (isset($_GET['list']) && $_GET['list'] == '2'): ?>
  92.             <div class="form-group">
  93.                 <div>
  94.                     <label class="desc">Updates the properties of a list</label>
  95.                 </div>
  96.                 <label for="apiKey"> Api Key </label>
  97.                 <input type="text" name="apiKey" class="form-control" value="<?php echo $api; ?>" id="apiKey" placeholder="Api Key">
  98.                 <label for="userID"> User ID </label>
  99.                 <input type="text" name="UserID" class="form-control" value="<?php echo $newsmanID; ?>" id="userID" placeholder="User Id">
  100.                 <label class="desc1">Step 1: Set your list id and press List Properties button</label>
  101.                 <input type="text" name="listId" class="form-control" value="<?php echo $listId; ?>" id="listId" placeholder="List Id">
  102.                 <div class="divSpacing">
  103.                     <button type="submit" name="seeProperties" class="btn btn-default btn-lg"> See properties</button>
  104.                 </div>
  105.                 <div>
  106.                     <label class="desc1">Step 2: Type a property from the listed ones and set the new value</label>
  107.                 </div>
  108.                 <label for="propName"> Property</label>
  109.                 <input type="text" name="propName" class="form-control" id="propName" placeholder="Property Name">
  110.                 <label for="newPropName">New Property Value</label>
  111.                 <input type="text" name="newPropName" class="form-control" id="newPropName" placeholder="New Property Value">
  112.                 <div class="divSpacing">
  113.                 <button type="submit" name="updateProperties" class="btn btn-primary"> Update Properties</button>
  114.                     </div>
  115.             </div>
  116.         <?php endif; ?>
  117.     </form>
  118.   <!-- <label for="exampleInputEmail1" > Email address </label >
  119.    <input type = "email" name = "email" class="form-control" id = "emailId" placeholder = "Email" > -->
  120. </div>
  121. </body>
  122.  
  123. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement