Azərbaycan dili Bahasa Indonesia Bosanski Català Čeština Dansk Deutsch Eesti English Español Français Galego Hrvatski Italiano Latviešu Lietuvių Magyar Malti Mакедонски Nederlands Norsk Polski Português Português BR Românã Slovenčina Srpski Suomi Svenska Tiếng Việt Türkçe Ελληνικά Български Русский Українська Հայերեն ქართული ენა 中文
Subpage under development, new version coming soon!

Subject: PHP

2007-10-30 15:10:47
I can't indent the ifs.... Sorry!
Maybe it doesn't fully work, use it as a guide.

$user = "Senhor_Castor";
$password = "password";
// Creates the http object
$http = &new http(HTTP_V11, false);
$http->host = "online.sokker.org";
// saves it on the Session
$_SESSION["http"] = $http;
// array with user and password
$form = array('ilogin' => $user,'ipassword' => $password);
//Posts the request
$code = $http->post("/start.php?session=xml", $form, 'http://'.$http->host);
//If the request went fine
if ($code == HTTP_STATUS_OK) {
//Gets the response and from the response, gets the team Id
$response = $http->get_response_body();
$data = explode("=",$response);
// gets the team ID
$teamId = $data[1];
}

// This for example, returns players.xml using the teamId
function downloadPlayersXML($teamId) {
$http = $_SESSION["http"];
//Sets parameters
$form = array();
//Posts the request
$code = $http->post('/xml/players-'.$teamId.'.xml', $form, 'http://'.$http->host);
if ($code == HTTP_STATUS_OK) {
return $http->get_response_body();
}
else {
return -1;
}
}
(edited)
(edited)
2007-10-30 15:13:05
Good luck with learning PHP jeetn :)
2007-10-30 15:13:32
Thanks I'll try it :)
2007-10-30 15:14:30
Normally it may not be a problem :)

I allready know Java, Javascript, ASP, VB, RPG, html, xhtml, css...
2007-10-30 16:02:14
I allready come for help :)

When I open that page, I get an error which leads me to this line:

$http = &new http(HTTP_V11, false);


The error is:

Fatal error: Class 'http' not found in /home/jump/domains/jumpgenval.be/public_html/test.php on line 13



Can't find that much info on that error :s
2007-10-30 16:28:26
I FORGOT THAT http.inc was a library i get from:

HTTP.inc

sorry!
2007-10-30 16:47:10
It works ;)

edit: let me tell you differently:

I don't get any errors and also no output... echo "test" works, echo $teamId works


But I don't get my xml with players... Have to look a bit more now :)
(edited)
2007-10-30 17:09:10
Solved it :)

Now I got to order the data I get a bit more...

Guess I need a xmlparser to do so?
2007-10-30 17:46:44
Yes. XMLReader should work for you.
2007-10-30 17:51:09
I always thought you had to do it with the curl command, but http is another option?
2007-10-30 18:04:59
Http.php is a file where an objet is defined. Maybe inside uses curl or whatever, i don't know, i just use http->post, http-get and those functions provided by that library.

I don't know how it works, and i don't care either.
:)
2007-10-30 19:58:58
This is my current code:

[i]
function contents($parser, $data)
{
echo $data;
}

function startTag($parser, $data)
{
echo "";
}

function endTag($parser, $data)
{
echo "";
}

$xml_parser = xml_parser_create();

xml_set_element_handler($xml_parser, "startTag", "endTag");

xml_set_character_data_handler($xml_parser, "contents");

$fp = fopen($xml, "r");

$data = fread($fp, 80000);

if(!(xml_parse($xml_parser, $data, feof($fp)))){
die("Error on line " . xml_get_current_line_number($xml_parser));
}

xml_parser_free($xml_parser);

fclose($fp);
?>[/i]


I get an error he doesn't recognize fread, feof and fclose... fopen he does recognize :s

edit: Had to leave a part away cause he did not want to post it :s
(edited)
2007-10-30 21:59:25
Message deleted

2007-10-31 11:41:06
The code above sucks :)

Allready have new code which works ;)

Now I've got to work my way through different xml files to get what I want... That is the username and teamname of all 4th and 5th division teams of belgium :)
2007-10-31 11:44:02
You don't need to do that manually, you can find it with the XML interface.
2007-10-31 11:54:20
But I still need to write the code ;)

And to get all those name's I have to make several of loops...

But right now I'm still figuring out how to get all the names of my players...

That's difficult enough for the moment :)