function deleteItem($itemId) { global $accessToken, $connectHost, $requestHeaders; $response = Unirest\Request::delete($connectHost . '/v1/me/items/' . $itemId, $requestHeaders); if ($response->code == 200) { error_log('Successfully deleted item'); return $response->body; } else { error_log('Item deletion failed'); return NULL; } }
public function testDelete() { $response = Unirest\Request::delete('http://mockbin.com/request', array('Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'), array('name' => 'Mark', 'nick' => 'thefosk')); $this->assertEquals(200, $response->code); $this->assertEquals('DELETE', $response->body->method); }
public function testDelete() { $response = Unirest\Request::delete('http://httpbin.org/delete', array( 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' ), array( 'name' => 'Mark', 'nick' => 'thefosk' )); $this->assertEquals(200, $response->code); $data = $response->body->data; $this->assertTrue(empty($data)); }
public function delete($url) { Unirest\Request::auth($this->login, $this->pass); Unirest\Request::defaultHeader('User-Agent', $this->service . " (" . $this->mail . ")"); $response = Unirest\Request::delete($this->root . $url . '.json'); if (floor($response->code / 100) >= 4) { throw new Error($response->body->errors->error[0]); } return $response->body; }