Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [XML][PHP]Błąd function children() on a non-object podczas parsowania
mlody69
post
Post #1





Grupa: Zarejestrowani
Postów: 183
Pomógł: 0
Dołączył: 18.05.2009

Ostrzeżenie: (0%)
-----


Witam,
posiadam następujący kod:
  1. function List($campaign_id)
  2. {
  3. require 'config.php';
  4. $date = '2011-07-31';
  5. //$date = date('Y-m-d');
  6.  
  7. $ch = curl_init();
  8. $url = "https://{$settings['client_name']}.directtrack.com/apifleet/rest/{$settings['client_name']}/".
  9. "{$settings['access_id']}/leadDetail/campaign/{$campaign_id}/".$date."/";
  10. $headers[] = "Authorization: Basic ".base64_encode($settings['username'].":".$settings['password']);
  11.  
  12. // Initiate the REST call via curl
  13. $ch = curl_init($url);
  14.  
  15. // Set the HTTP method to GET
  16. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  17. // Add the headers defined above
  18. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  19. // Don't return headers
  20. curl_setopt($ch, CURLOPT_HEADER, false);
  21. // Return data after call is made
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  23.  
  24. $response = curl_exec($ch);
  25. curl_close($ch);
  26.  
  27. $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
  28.  
  29. foreach($xml->children() as $lead)
  30. {
  31. $a = explode('/',$lead['location']);
  32. $return[] = array_pop($a);
  33. }
  34. if(isset($return))
  35. return $return;
  36. else
  37. return false;
  38. }

Skrypt zwraca taki bład:
Cytat
Fatal error: Call to a member function children() on a non-object in
. Próbowałem już wszystkiego i nadal nie wiem dlaczego tak się dzieje.

Ten post edytował mlody69 4.08.2012, 14:16:09
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 02:44