Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove xml parsing and content-type detection from response parsing
  • Loading branch information
Kevin Burke committed Apr 26, 2012
1 parent bb014c6 commit 784638f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Expand Up @@ -8,3 +8,10 @@ Released on March 14, 2012

- If no version is passed to the Services_Twilio constructor, the library will
default to the most recent API version.

Version 3.3
-----------

Use the 'Accept-Charset' header to specify we want to receive UTF-8 encoded
data from the Twilio API. Remove unused XML parsing logic, as the library never
requests XML data.
23 changes: 1 addition & 22 deletions Services/Twilio.php
Expand Up @@ -145,16 +145,7 @@ private function _processResponse($response)
if (empty($headers['Content-Type'])) {
throw new DomainException('Response header is missing Content-Type');
}
switch ($headers['Content-Type']) {
case 'application/json':
return $this->_processJsonResponse($status, $headers, $body);
break;
case 'text/xml':
return $this->_processXmlResponse($status, $headers, $body);
break;
}
throw new DomainException(
'Unexpected content type: ' . $headers['Content-Type']);
return $this->_processJsonResponse($status, $headers, $body);
}

private function _processJsonResponse($status, $headers, $body) {
Expand All @@ -170,16 +161,4 @@ private function _processJsonResponse($status, $headers, $body) {
);
}

private function _processXmlResponse($status, $headers, $body) {
$decoded = simplexml_load_string($body);
if (200 <= $status && $status < 300) {
return $decoded;
}
throw new Services_Twilio_RestException(
(int)$decoded->Status,
(string)$decoded->Message,
(string)$decoded->Code,
(string)$decoded->MoreInfo
);
}
}

0 comments on commit 784638f

Please sign in to comment.