You are here

function _facebook_album_api_response_to_array in Facebook Album 7.3

Same name and namespace in other branches
  1. 7.2 facebook_album.module \_facebook_album_api_response_to_array()

Convert the API response into an array based on the content type Currently only, json and plain-text responses are supported

Parameters

$content_type: The type of content returned in the response. I.e. (json, plain-text, html)

$response: The actual response to convert

Return value

mixed A response converted to an array

1 call to _facebook_album_api_response_to_array()
_facebook_album_fetch_api_response in ./facebook_album.module
Make a curl request to the specified url and return a converted response

File

./facebook_album.module, line 605

Code

function _facebook_album_api_response_to_array($content_type, $response) {
  if (strstr($content_type, 'plain')) {
    $a = explode(',', $response);
    foreach ($a as $response) {
      $b = explode('=', $response);
      $array[$b[0]] = $b[1];
    }
    $response = $array;
  }
  else {
    if (strstr($content_type, 'json')) {
      $response = json_decode($response, TRUE);
    }
    else {
      $response['error']['message'] = t("Unrecognized response type. Unable to parse data.");
      $response['error']['code'] = 10000;
    }
  }
  if (!isset($response['data'])) {
    $response['data'] = [];
  }
  return $response;
}