title: Attempting to parse XML/JSON from an API output
body: <p>OK... I am using PHP 5 (be gentle, still learning PHP). CURL is enabled. Attempting to load XML or JSON output from an API to an object and nothing happens. When I manually execute the URL in question, I get what I am expecting.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class XmlToJson {
      public function Parse ($url) {
          $fileContents = file_get_contents($url);
          $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
          $fileContents = trim(str_replace('"', "'", $fileContents));
          $simpleXml = simplexml_load_string($fileContents);
          $json = json_encode($simpleXml);
          return $json;
      }
  }
  
  $_MySQLServer = "localhost";
  $_MySQLServerUserName = "";
  $_MySQLServerPassword = "";
  $_MySQLDatabaseName = "";
  
  $_SSActiveWear_UserID = "*****";
  $_SSActiveWear_APIKey = "*****";
  $_SSActiveWear_APIBaseURL = "https://*****/v2";
  $_CategoryURL = "/categories/";
  $_StylesURL = "/styles/";
  $_ProductsURL = "/products/";
  $_SpecsURL = "/specs/";
  $_SSActiveWear_MediaType = "xml";
  
  //$_conn = mysqli_connect($_MySQLServer, $_MySQLServerUserName, $_MySQLServerPassword, $_MySQLDatabaseName);
  
  //Insert or Update Categories
  $_URL = $_SSActiveWear_APIBaseURL . $_CategoryURL;
  $_URL = $_URL . "?mediatype=$_SSActiveWear_MediaType&amp;UserName=$_SSActiveWear_UserID&amp;Password=$_SSActiveWear_APIKey";
  
  $OBJ = simplexml_load_string($_URL);
  
  print_r($OBJ);
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Added the following code:</p>
  
  <pre><code>$xml = simplexml_load_file($_URL) or die("Error: Cannot create object");
  print_r($xml);
  </code></pre>
  
  <p>and it dies. Does that mean that there is something wrong with the code?</p>