Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Panel Aukcji Allegro
S3baso
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 16.07.2010

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


PLIK: Pobierz_Aukcje.php wygląda tak:
  1. <?php
  2. $op['login'] = 'xxxx';
  3. $op['haslo'] = 'xxxx';
  4. $op['country_code'] = '1'; // dla allegro
  5. $op['webapi_key'] = 'xxxx';
  6.  
  7. require_once('./allegro.inc.php');
  8.  
  9. $all = new Allegro($op);
  10. $all -> getAuctionsFromAllegro(6);
  11. ?>


Witajcie, próbuję napisać własny panel aukcji allegro i napotkałem 1 problem a mianowicie gdy otwieram plik pobierz_aukcje.php wyskakuje mi taki error:
Kod
Fatal error: Call to undefined method Allegro::getAuctionsFromAllegro() in pobierz_aukcje.php on line 10


Prosiłbym o jak najszybszą pomoc (IMG:style_emoticons/default/smile.gif)




#EDIT
#phpion
hahaha OMG nie spojrzalem, ze klucz jest niepoprawny

Ten post edytował S3baso 19.07.2011, 10:31:26
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
S3baso
post
Post #2





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 16.07.2010

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


Hmmm... Coś tu jest grubo namieszane, klucz musi być prawidłowy bo jest wpisany ok.. I został wygenerowany dziś rano.

Nieco dodałem i zmodyfikowałem to i niestety kolejne problemy się pojawiają:
Kod
<?php

class Allegro {

{.....}
                                 $aukcje[$lp++]=array(
                                 'id' => $aukcja['it-id'],
                                 'name' => $aukcja['it-name'],
                                 'price' => $price, //pobiera cenę
                                 'time' => (time() + $aukcja['it-time-left']),
                                 'foto_count' => $aukcja['it-foto-count'],
                                 'img' => $obrazek,
                        'is_auctions'=>$is_auctions
                                 );
                                 }
                                 return true;
                                 }

private function getAuctionsFromAllegroRaw($offset=0)
        {
        $msg=array(
                'user-id' => "14165349",
                'webapi-key' => WEBAPI_KEY,
                'country-id' => 1,
                'user-email' => '',
                'offset' => $offset);
        $response= $this->soap->__soapCall('doGetUserItems', $msg);
        if($response['user-item-count'] == 0) die('Brak aukcji !');
        $this->howManyAuctions = $response['user-item-count'];
        return $response;
        }
private function getImage($url='')
{
        if(empty($url)) return '';
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
        $output = curl_exec($ch);
        return $output;
}

private function saveAuctions($aukcje=array())
{
$aukcje = serialize($aukcje);
$file =@ fopen($this->path.'aukcje.txt', "w") OR die('Nie udalo sie zapisac aukcji ! Brak pliku aukcje.txt z prawami do zapisu !');
fwrite($file, $aukcje);
fclose($file);
return;

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Nie mogę się połączyć z memcache!");
if(!$memcache->set($this->allegro_login, $aukcje, false, $this->saveTime)) die("Nie udało się zapisać danych do memcache'a\"); // 30 minut
}



public function readAuctions()
        {
        if(!file_exists($this->path.'aukcje.txt')) die('Brak danych aukcji');
        $this->aukcje = unserialize( file_get_contents( $this->path.'aukcje.txt') );
        //echo 'Jest '.count($this->aukcje).' aukcji';
        }

public function parsePanel()
        {
session_start();
if(isset($_GET['aukcja']))
{
$id = intval($_GET['aukcja']);
$url = $this->getUrlAuction($id);
header('Location: '.$url);
exit;
                }

        // generacja obrazka
        if(isset($_GET['img']))
                {
                $id = intval($_GET['img']);
                $usun = false;
                $id_aukcji = ($id - 1);
                $do_konca = 'DO KOŃCA : ';
                $act = time();
                //print_r($end); exit;
                $roznica = $this->aukcje[$id_aukcji]['time'] - $act;
                //die($act.\' - \'.$end.\' = \'.$roznica);
                        if($roznica>86400)
                                {
                                $days = floor($roznica/86400);
                                $do_konca.=($days==1)?'1 DZIEŃ':$days.' DNI';
                                }
                        else {
                                if($roznica>3600)
                                        $do_konca.=floor($roznica/3600).' godz.';
                                else    {
                                        $min = floor($roznica/60);
                                        if($min>0)
                                                $do_konca.=$min.' min.';
                                        else    {
                                                $do_konca = 'ZAKOŃCZONA';
                                                }
                                        }
                                }
                        //echo date(\"Y-m-d H:i:s\", $aukcje[$id][\'time\']).\' \'; die($do_konca);
                $img = imagecreatefromjpeg($this->path.'panel_bg.jpg');
                $sW = imagesx( $img );
                $sH = imagesy( $img );

                $red    = imagecolorallocate($img, 255, 0, 0);
                $black  = imagecolorallocate($img, 0, 0, 0);
                $green  = imagecolorallocate($img, 30, 60, 0);
                $blue   = imagecolorallocate($img, 0, 102, 153);
                $bordo  = imagecolorallocate($img, 206, 0, 0);
                $size = 8;
                $font = $this->path.'verdana.ttf';
                //print_r($this->aukcje); exit;
                $nazwy = explode("\n", wordwrap($aukcje[$id]['name'], 20, "\n"));
                $kup_teraz =($this->aukcje[$id_aukcji]['is_auctions'])? 'KUP TERAZ '.$this->aukcje[$id_aukcji]['price'].'zł':'LICYTACJA '.$this->aukcje[$id_aukcji]['price'].'zł';


                $white = imagecolorallocate($img, 0, 0, 0);
                $posY = 130;
                $posX=0;
                foreach($nazwy as $nazwa)
                        {
                        $arr = imagettfbbox($size, 0, $font, $nazwa);
                        $width = abs($arr[2] - $arr[0]) + 5;
                        $height = abs($arr[1] - $arr[7]) + 1;
                
                        $posX = ($sW/2) - ($width/2);
                        //$posX = $width;
                        //$posY = $sH;
                        imagettftext($img, $size, 0, $posX, $posY - 5, $black, $font, $nazwa);
                        $posY+=$height + 3;
                        }

                // KUP TERAZ
                $size =(strlen($kup_teraz)>10)?9:8;
                $arr = imagettfbbox($size, 0, $font, $kup_teraz);      
                $width = abs($arr[2] - $arr[0]) + 5;
                $height = abs($arr[1] - $arr[7]) + 1;
                $posY = ($sH - $height - 11);
                $posX = ($sW/2) - ($width/2);
                imagettftext($img, $size, 0, $posX, $posY, $bordo, $font, $kup_teraz);

                // DO KOŃCA
                $size = 6;
                $arr = imagettfbbox($size, 0, $font, $do_konca);
                $width = abs($arr[2] - $arr[0]) + 5;
                $height = abs($arr[1] - $arr[7]) + 1;
                $posY = ($sH - 7);
                $posX = ($sW/2) - ($width/2);
                imagettftext($img, $size, 0, $posX, $posY, $green, $font, $do_konca);

                // Zdjęcie
                if(file_exists($this->aukcje[$id_aukcji]['img']))
                        {
                        $miniaturka = imagecreatefromjpeg($this->aukcje[$id_aukcji]['img']);
                        $zW = imagesx( $miniaturka );
                        $zH = imagesy( $miniaturka );
                        $dst_x = (($sW/2) - ($zW/2));
                        $dst_y = 12;
                        imagecopy( $img, $miniaturka, $dst_x, $dst_y, 0, 0, $zW, $zH );
                        imagedestroy( $miniaturka );
                        }
                //else die($aukcje[$id_aukcji][\'img\']);
                // Delete
                
                // Output
                $_SESSION['panel_aukcji'][$id] = $this->aukcje[$id_aukcji]['id'];
                header(\'Content-Type: image/jpeg\');
                imagejpeg($img, NULL, 100);
                imagedestroy($img); exit;
                }
        return;
        }

private function getRandomAuctionId()
{
$id = rand(1, count($this->aukcje) );
while($this->aukcje[$id]['time'] <= 0)
{
$id = rand(1, count($this->aukcje) );
}
return $id;
}

private function getUrlAuction($id=0)
        {
//      print_r($_SESSION);
        if(!isset($_SESSION['panel_aukcji'][$id])) die('Nie ma takiej aukcji w pamięci!');
        $dane =(string) $_SESSION['panel_aukcji'][$id];
        return 'http://www.allegro.pl/item'.$_SESSION['panel_aukcji'][$id].'_aukcja.html';
        }

public function printAuctions()
        {
        foreach($this->aukcje as $a)
                {
                echo date("Y-m-d H:i:s", $a['time']).", cena = ".$a['price']."<br />\n";
                }
        }

}
?>


Linia 162:
Kod
if(isset($_GET['aukcja']))


ERORR:
Kod
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ogrodni2/public_html/panel/dodatki/allegro.php on line 162

Nie mam pojęcia co oznacza ten error, szukałem męczyłem się i nic..
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 27.12.2025 - 22:40