Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge pull request #205 from naoyukik/allow-delete
Browse files Browse the repository at this point in the history
Added DELETE Support
  • Loading branch information
J7mbo authored Aug 4, 2016
2 parents 8ed941d + 1d109b8 commit 6a8982b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions TwitterAPIExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ public function getPostfields()
*/
public function buildOauth($url, $requestMethod)
{
if (!in_array(strtolower($requestMethod), array('post', 'get', 'put')))
if (!in_array(strtolower($requestMethod), array('post', 'get', 'put', 'delete')))
{
throw new Exception('Request method must be either POST, GET or PUT');
throw new Exception('Request method must be either POST, GET or PUT or DELETE');
}

$consumer_key = $this->consumer_key;
Expand Down Expand Up @@ -283,7 +283,7 @@ public function performRequest($return = true, $curlOptions = array())
$getfield = $this->getGetfield();
$postfields = $this->getPostfields();

if (strtolower($this->requestMethod) === 'put')
if (in_array(strtolower($this->requestMethod), array('put', 'delete')))
{
$curlOptions[CURLOPT_CUSTOMREQUEST] = $this->requestMethod;
}
Expand Down
15 changes: 14 additions & 1 deletion test/TwitterAPIExchangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,17 @@ public function testPut()
/** If we get this back, then it looks like we can support PUT! :-) **/
$this->assertContains('UNAUTHORIZED_CLIENT_APPLICATION', $data);
}
}

public function testDelete()
{
$params = array();

// foobaa is sandbox Ads account id
$url = 'https://ads-api-sandbox.twitter.com/1/accounts/foobaa';
$method = 'DELETE';

$data = $this->exchange->request($url, $method, $params);

$this->assertContains('UNAUTHORIZED_CLIENT_APPLICATION', $data);
}
}

0 comments on commit 6a8982b

Please sign in to comment.