Example #1
0
 public function put($url, $data, $headers = array())
 {
     $success = false;
     for ($i = 0; $i < $this->retries && !$success; $i++) {
         try {
             $result = parent::put($url, $data, $headers);
             $success = true;
         } catch (Exception $e) {
             $success = false;
         }
     }
     if (!$success) {
         throw $e;
     }
     return $result;
 }
Example #2
0
 /**
  * Perform HTTP PUT
  *
  * @param string $url
  * @param array $data
  * @param array $headers
  * @return string
  */
 public function put($url, $data, $headers = array())
 {
     return parent::put($url, $this->jsonEncode($data), $headers);
 }
Example #3
0
    $contactdata = array('Firstname' => $firstname, 'Lastname' => $lastname, 'PhoneNumber' => $phonenumber);
    $contactjson = $pest->post('/contacts', $contactdata);
    $contactarray = json_decode($contactjson, true);
    $contactId = $contactarray[ContactId];
    echo "<br>Created contact with id: " . $contactId;
} catch (Exception $e) {
    echo "<br>Caught exception when creating contact : " . $e->getMessage() . "<br>";
}
echo "<h1>2. Getting the contact by its phonenumber and updating it.</h1>";
try {
    $contactjson = $pest->get('/contacts/phonenumber/' . $phonenumber);
    $contactarray = json_decode($contactjson, true);
    echo "<br>Retrieved contact with id: " . $contactarray[ContactId] . ", should be identical with " . $contactId . " from part 1.<br>";
    $contactarray[Description] = $description;
    $contactjson = json_encode($contactarray);
    $pest->put('/contacts/' . $contactarray[ContactId], $contactjson);
    echo "<br>Updated contact<br>";
} catch (Exception $e) {
    echo "<br>Caught exception when retrieving or updating contact : " . $e->getMessage() . "<br>";
}
echo "<h1>3. Sending a message to the contact</h1>";
try {
    $messagedata = array('Receivers' => "/contacts/" . $contactId, 'SenderNumber' => $sendernumber, 'Text' => $messagetext);
    $messagejson = $pest->post('/messages', $messagedata);
    $messagearray = json_decode($messagejson, true);
    echo "<br>Message was sent! MessageId: " . $messagearray[MessageId];
} catch (Exception $e) {
    echo "<br>Caught exception when sending message : " . $e->getMessage() . "<br>";
}
echo "<h1>4. Deleting contact.</h1>";
try {
Example #4
0
 public function put($url, $data, $headers = array())
 {
     return parent::put($url, $data, $headers);
 }