Wednesday, 15 January 2014

php - Get data from XML sites -



php - Get data from XML sites -

i want info site based on xml's. problem need logged publicuser without password.

i have tryed:

$url = 'http://ip/wcd/system_counter.xml'; $content = file_get_contents($url); echo $content

but this:

err en reloginattempt /wcd/index.html false

this xml code used loggin:

<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="top.xsl" type="text/xsl"?> <mfp> <selno>auto</selno> <langno>en</langno> <service><setting><authsetting><authmode><authtype>none</authtype> <liston>false</liston> <publicuser>true</publicuser> <boxadmin>false</boxadmin> </authmode><trackmode><tracktype>none</tracktype></trackmode></authsetting> <middleserversetting><controllist><arraysize>0</arraysize></controllist><screen> <id>0</id></screen></middleserversetting> </setting></service><langdummy>false</langdummy></mfp>

is there way send user when want xml info ?

you cannot access pages requiring posted login info using file_get_contents. instead need utilize curl. along these lines:

$ch = curl_init($url); // url want phone call curl_setopt_array( $ch, array( curlopt_returntransfer => 1, curlopt_post => 1, curlopt_postfields => $login_xml, // xml login in string form ) ); //getting response server $response = curl_exec($ch); echo curl_error($ch); curl_close($ch);

php xml

No comments:

Post a Comment