Klein probleempje met Bot
Kevin Blokzijl
24/02/2012 19:39:54Hallo,
Ik heb een kleine bot gedownload om iets van mijn website te displayen:
Maar nu pakt hij de punten niet en geeft hij alleen maar
Ik heb Paysafe Punten!
En geeft hij een foutmelding bij
$punten = $punten[1];
Notice: Undefined offset: 1
Wie weet hoe ik dit oplos?
Alvast bedankt ;)
Ik heb een kleine bot gedownload om iets van mijn website te displayen:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
error_reporting(E_ALL);
$ch = curl_init();
$user = "**";
$pass = "**";
curl_setopt ($ch, CURLOPT_URL, 'INLOG PAGINA');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'gebruikersnaam=' . $user . '&wachtwoord=' . $pass);
curl_setopt ($ch, CURLOPT_HEADER, FALSE);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0');
curl_exec ($ch);
curl_setopt ($ch, CURLOPT_URL, 'HOMEPAGINA');
$content = curl_exec ($ch);
preg_match('#Je hebt (.*) punten op dit moment.#', $content, $punten);
$punten = $punten[1];
$img_content = 'Ik heb ' . $punten . ' Paysafe Punten!';
$img = imagecreate(700, 15);
$bg = imagecolorallocate($img, 255, 255, 255);
$kleur = imagecolorallocate($img, 200, 100, 0);
imagestring($img, 8, 2, 1, $img_content, $kleur);
imagepng($img, 'gp.png');
imagedestroy($img);
echo $img_content;
?>
error_reporting(E_ALL);
$ch = curl_init();
$user = "**";
$pass = "**";
curl_setopt ($ch, CURLOPT_URL, 'INLOG PAGINA');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'gebruikersnaam=' . $user . '&wachtwoord=' . $pass);
curl_setopt ($ch, CURLOPT_HEADER, FALSE);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0');
curl_exec ($ch);
curl_setopt ($ch, CURLOPT_URL, 'HOMEPAGINA');
$content = curl_exec ($ch);
preg_match('#Je hebt (.*) punten op dit moment.#', $content, $punten);
$punten = $punten[1];
$img_content = 'Ik heb ' . $punten . ' Paysafe Punten!';
$img = imagecreate(700, 15);
$bg = imagecolorallocate($img, 255, 255, 255);
$kleur = imagecolorallocate($img, 200, 100, 0);
imagestring($img, 8, 2, 1, $img_content, $kleur);
imagepng($img, 'gp.png');
imagedestroy($img);
echo $img_content;
?>
Maar nu pakt hij de punten niet en geeft hij alleen maar
Ik heb Paysafe Punten!
En geeft hij een foutmelding bij
$punten = $punten[1];
Notice: Undefined offset: 1
Wie weet hoe ik dit oplos?
Alvast bedankt ;)
Gewijzigd op 24/02/2012 21:10:55 door Kevin Blokzijl
PHP hulp
20/04/2024 06:26:37Erwin H
24/02/2012 19:43:00$punten = $punten[0];
misschien? Arrays zijn 0 based in php (en alle andere talen die ik ken). Dus het eerste element is 0, niet 1.
misschien? Arrays zijn 0 based in php (en alle andere talen die ik ken). Dus het eerste element is 0, niet 1.
Kevin Blokzijl
24/02/2012 19:45:34Erwin H op 24/02/2012 19:43:00:
$punten = $punten[0];
misschien? Arrays zijn 0 based in php (en alle andere talen die ik ken). Dus het eerste element is 0, niet 1.
misschien? Arrays zijn 0 based in php (en alle andere talen die ik ken). Dus het eerste element is 0, niet 1.
Notice: Undefined offset: 0
Dan krijg ik die. ik heb het scriptje van internet gehaald, en dacht dat ik zo even kon veranderen, maar dat was dus niet zo.