Permalink
Browse files

remove xml parsing and content-type detection from response parsing

  • Loading branch information...
Kevin Burke
Kevin Burke committed Apr 26, 2012
1 parent bb014c6 commit 784638f8342332440b1189663ff050826b8caf1d
Showing with 8 additions and 22 deletions.
  1. +7 −0 CHANGES
  2. +1 −22 Services/Twilio.php
@@ -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.
@@ -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) {
@@ -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.