Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- if ($_POST) {
- switch ($_GET['list']) {
- case 1:
- //getProps
- $newsmanID = $_POST["UserID"];
- $api = $_POST["apiKey"];
- $listId = $_POST["listId"];
- $client = new Newsman_Client($newsmanID, $api);
- $ret = $client->list->getProps(
- $listId
- );
- if (!is_array($ret)) {
- // handle error here
- die("Error on method list.getProps");
- }
- print "<pre>";
- print_r($ret);
- print "</pre>";
- break;
- case 2:
- try {
- $newsmanID = $_POST["UserID"];
- $api = $_POST["apiKey"];
- $listId = $_POST["listId"];
- $client = new Newsman_Client($newsmanID, $api);
- $ret = $client->list->getProps(
- $listId
- );
- print "<pre>";
- print_r($ret);
- print "</pre>";
- if (($_POST["propName"] != '') && ($_POST["newPropName"] != '')) {
- $ret = $client->list->updateProps(
- $listId,
- array($_POST["propName"] => $_POST["newPropName"])
- );
- $ret = $client->list->getProps(
- $listId
- );
- echo 'Updated...';
- print "<pre>";
- print_r($ret);
- print "</pre>";
- }
- } catch (Exception $ex) {
- echo 'Update props method error. Make sure you introduced your data correctly.' . $ex;
- }
- break;
- }
- }
- }
- catch (Exception $e) {
- print $e;
- }
- ?>
- <form id="apiForm" method="post">
- <!-- getProps -->
- <?php if(isset($_GET['list']) && $_GET['list'] == '1'): ?>
- <div class="form-group">
- <div>
- <label class="desc">Returns a hash array with the properties of a list</label>
- </div>
- <label for="apiKey"> Api Key </label>
- <input type="text" name="apiKey" class="form-control" id="apiKey" placeholder="Api Key">
- <label for="listId"> List Id </label>
- <input type="text" name="listId" class="form-control" id="listId" placeholder="List Id">
- <label for="userID"> User ID </label>
- <input type="text" name="UserID" class="form-control" id="userID" placeholder="User Id">
- </div>
- <div class="divSpacing">
- <button type="submit" name="seeProperties" class="btn btn-primary"> See properties</button>
- </div>
- <!-- getProps -->
- <?php elseif (isset($_GET['list']) && $_GET['list'] == '2'): ?>
- <div class="form-group">
- <div>
- <label class="desc">Updates the properties of a list</label>
- </div>
- <label for="apiKey"> Api Key </label>
- <input type="text" name="apiKey" class="form-control" value="<?php echo $api; ?>" id="apiKey" placeholder="Api Key">
- <label for="userID"> User ID </label>
- <input type="text" name="UserID" class="form-control" value="<?php echo $newsmanID; ?>" id="userID" placeholder="User Id">
- <label class="desc1">Step 1: Set your list id and press List Properties button</label>
- <input type="text" name="listId" class="form-control" value="<?php echo $listId; ?>" id="listId" placeholder="List Id">
- <div class="divSpacing">
- <button type="submit" name="seeProperties" class="btn btn-default btn-lg"> See properties</button>
- </div>
- <div>
- <label class="desc1">Step 2: Type a property from the listed ones and set the new value</label>
- </div>
- <label for="propName"> Property</label>
- <input type="text" name="propName" class="form-control" id="propName" placeholder="Property Name">
- <label for="newPropName">New Property Value</label>
- <input type="text" name="newPropName" class="form-control" id="newPropName" placeholder="New Property Value">
- <div class="divSpacing">
- <button type="submit" name="updateProperties" class="btn btn-primary"> Update Properties</button>
- </div>
- </div>
- <?php endif; ?>
- </form>
- <!-- <label for="exampleInputEmail1" > Email address </label >
- <input type = "email" name = "email" class="form-control" id = "emailId" placeholder = "Email" > -->
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement