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 (1 - 12)
Wilu88
post
Post #2





Grupa: Zarejestrowani
Postów: 158
Pomógł: 6
Dołączył: 7.03.2010

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


A czy ścieżka do pliku allegro.inc.php jest prawidłowa?
Go to the top of the page
+Quote Post
thek
post
Post #3





Grupa: Moderatorzy
Postów: 4 362
Pomógł: 714
Dołączył: 12.02.2009
Skąd: Jak się położę tak leżę :D




Jak byk pisze: "Odwołanie do nie istniejącej metody Allegro::getAuctionsFromAllegro() w pliku pobierz_aukcje.php w linii 10"
Wymagania: angielski na poziomie komunikatywnym...

Wilu... Była by nieprawidłowa, to by sypnęło błedem podczas tworzenia obiektu linijkę wyżej (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
S3baso
post
Post #4





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

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


Gdyby byla nie prawidłowa wywaliło by error: No such file or directory, owszem jest prawidłowa

No i ok, dodałem sobie taką funkcję do klasy Allegro:
  1. public function getAuctionsFromAllegro()
  2. {
  3. $msg = array(
  4. 'user-id' => $this->user_id,
  5. 'webapi-key' => $this->webapi_key,
  6. 'country-id' => $this->country_code,
  7. 'offset' => $this->offset
  8. );
  9. $allAuctions = $this->soap->__call('doGetUserItems', $msg);
  10.  
  11. }


Ale teraz wywala mi taki error(i tak miałem w kółko) :

Kod
Fatal error: Call to a member function __call() on a non-object in /home/seba/public_html/tester/n/dodatki/allegro.inc.php on line 43

Linia 43:
Kod
     $allAuctions = $this->soap->__call('doGetUserItems', $msg);


Umieszczona w

Kod
    public function getAuctionsFromAllegro()
    {
         $msg = array(
            'user-id' => $this->user_id,
            'webapi-key' => $this->webapi_key,
            'country-id' => $this->country_code,
            'offset' => $this->offset
        );
     $allAuctions = $this->soap->__call('doGetUserItems', $msg);    
  
   }





#EDIT

Emm... Tak się teraz zastanawiam i sądzę, że może to być spowodowane tym, że nie mam teraz istniejących aukcji ?

Ten post edytował S3baso 19.07.2011, 09:33:04
Go to the top of the page
+Quote Post
phpion
post
Post #5





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Pokaż zawartość pliku allegro.inc.php bo obawiam się, że jest on niekompletny. Błąd:
Cytat(S3baso @ 19.07.2011, 10:30:56 ) *
Kod
Fatal error: Call to a member function __call() on a non-object in /home/seba/public_html/tester/n/dodatki/allegro.inc.php on line 43

mówi o tym, ze $this->soap nie jest obiektem, a próbujesz na nim wywołać metodę.
Go to the top of the page
+Quote Post
S3baso
post
Post #6





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

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


Jest to całkiem możliwe, że coś zwaliłem (IMG:style_emoticons/default/smile.gif)

Proszę ciebie bardzo:

Kod
<?php
class Allegro {
public function __construct($opcje=array())
{
foreach($opcje as $n=>$v) $this->$n=$v;
}
public function login()
{
  $this->soap = new SoapClient('http://webapi.allegro.pl/uploader.php?wsdl', array('encoding'=>'UTF-8'));
  $this->soap->soap_defencoding = 'UTF-8';
  $this->soap->decode_utf8 = false;

  $params = array(
   'sysvar' => 1, // 1 dla AllegroWebApi
   'country-id' => $this->country_code,
   'webapi-key' => $this->webapi_key
  );
  $result = $this->soap->__soapCall('doQuerySysStatus',$params);
  $this->local_version = $result['ver-key'];

  $msg = array(
   'user-login' => $this->login,
   'user-password' => $this->haslo,
   'country-code' => $this->country_code,
   'webapi-key' => $this->webapi_key,
   'local-version' => $this->local_version
  );

  $response = $this->soap->__call('doLogin', $msg);
  $this->session_handle_part= $response['session-handle-part'];
  $msg= array('country-id'=> $this->country_code, 'user-login'=>$this->login);
  $this->user_id= $this->soap->__call('doGetUserID', $msg);
return true;
}
    public function getAuctionsFromAllegro()
    {
$msg=array(
  'user-id' => $this->user_id,
  'webapi-key' => $this->webapi_key,
  'country-id' => $this->country_code,
  'offset' => $this->offset);
$allAuctions= $this->soap->__call('doGetUserItems', $msg);
   }

}
?>
Go to the top of the page
+Quote Post
phpion
post
Post #7





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Przed wywołaniem $all->getAuctionsFromAllegro() musisz pewnie wykonać jeszcze $all->login(). Jednak jeszcze przed tym tworząc obiekt $all musisz w konstruktorze przekazać mu parametry, do których klasa odwołuje się w metodzie login np. country_code, webapi_key itd. (przejrzyj kod metody login()), czyli:
  1. $all = new Allegro(array(
  2. 'country_code' => 123,
  3. 'webapi_key' => 'abc123',
  4. // itd.
  5. ));
  6. $all->login();
  7. $all->getAuctionsFromAllegro();

Podstaw oczywiście poprawne dane (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post
S3baso
post
Post #8





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

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


Hmmm, zrobiłem to w ten sposób

Kod
    $all = new Allegro(array(
    'country_code' => '1',
    'webapi_key' => 'xxxkey',
    'login' => 'xx',
    'haslo' => 'xxx',
    ));
    $all->login();
//$all = new Allegro($op);
$all -> getAuctionsFromAllegro(6);



Ale twierdzi ze zle dane etc.. Blad sam zboacz:

Kod
Fatal error: Uncaught SoapFault exception: [ERR_WEBAPI_KEY] Access key to WebAPI is incorrect or has been blocked. Please contact the author of the program! in /home/seba/public_html/tester/n/dodatki/allegro.inc.php:32 Stack trace: #0 /home/seba/public_html/tester/n/dodatki/allegro.inc.php(32): SoapClient->__call('doGetUserID', Array) #1 /home/seba/public_html/tester/n/panel_aukcji.php(15): Allegro->login() #2 {main} thrown in /home/seba/public_html/tester/n/dodatki/allegro.inc.php on line 32
Go to the top of the page
+Quote Post
phpion
post
Post #9





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




W komunikacie błędu masz wszystko podane:
Cytat
Access key to WebAPI is incorrect or has been blocked

Jeśli nie rozumiesz to skorzystaj z Google Translate.
Go to the top of the page
+Quote Post
S3baso
post
Post #10





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
cycofiasz
post
Post #11





Grupa: Zarejestrowani
Postów: 711
Pomógł: 127
Dołączył: 5.07.2008
Skąd: Łódź

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


Skończ waść i wstydu oszczędź - sobie a nam nerwów. Nie znasz php - nie bierz się za modyfikację skryptu. Zleć to programiście albo zabierz się do nauki php od podstaw.
Go to the top of the page
+Quote Post
S3baso
post
Post #12





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

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


Chyba od tego jest to forum? Od pomocy
Go to the top of the page
+Quote Post
cycofiasz
post
Post #13





Grupa: Zarejestrowani
Postów: 711
Pomógł: 127
Dołączył: 5.07.2008
Skąd: Łódź

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


Wybrałeś zły dział, powinno być przedszkole. Ale i tam Ci napiszą że forum to nie parser. Żeby pomóc, osoba której pomagamy musi znać podstawy których nie posiadasz.
Go to the top of the page
+Quote Post

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: 23.08.2025 - 18:31