2016-06-01 1 views
0

Kann mir bitte jemand helfen. Ich erhalte einen schwerwiegenden Fehler beim folgenden PHP-Skript.Ermitteln eines schwerwiegenden Fehlers beim Aufruf der Methode "unidentified" Pass :: _ createpass()

Ich erhalte eine Fehlermeldung "unidentified method Pass :: _ createpass()" whick bezieht sich auf die vorletzte Zeile des folgenden Codes.

<?php 

$engine = Pass::start('xxxxxxxxxxxxxxxx'); 
$pass = $engine->createPassFromTemplate(xxxxxxxxxxxxxx); 
$engine->redirectToPass($pass); 

if (!function_exists('curl_init')) { 
    throw new Exception('Pass needs the CURL PHP extension.'); 
} 
if (!function_exists('json_decode')) { 
    throw new Exception('Pass needs the JSON PHP extension.'); 
} 

$engine = Pass::start($appKey); 
$values = array(
    'first' => 'John', 
    'last' => 'Platinum', 
); 

$images = array(
    'thumbnail' => 'image1.jpg' 
); 

$pass = $engine->createPassFromTemplate(5688667418918912, $values, $images); 
$passData = $engine->downloadPass($pass); 
$engine->redirectToPass($pass); 

class Pass 
{ 

    private $_appKey = null; 

    private $_endpoint = 'https://pass.center/api/v1'; 

    private $_debug = false; 

    private static $_instance = null; 

    private static $_imageTypes = array('icon', 'logo', 'strip', 'thumbnail', 'background', 'footer'); 

    const VERSION = '0.5'; 

    const USER_AGENT = 'PassSDK-PHP/0.5'; 

    public function __construct($appKey = null, $endpoint = null, $debug = false) 
    { 
     if (is_null($appKey)) { 
      throw new Exception('App Key required'); 
     } 
     $this->_appKey = $appKey; 
     if ($endpoint !== null) { 
      $this->_endpoint = $endpoint; 
     } 
     $this->_debug = $debug; 
    } 

    public static function start($appKey = null, $endpoint = null, $debug = false) 
    { 
     if (self::$_instance == null) { 
      self::$_instance = new self($appKey, $endpoint, $debug); 
     } 
     return self::$_instance; 
    } 

    public function createPassFromTemplate($templateId, $values = array(), $images = array()) 
    { 
     $resource = sprintf("https://xxxxxxx/api/v1/templates/names/Test/pass", $templateId); 
     return $this->_createPass($resource, $values, $images); 
    } 
} 

Ich hoffe, jemand kann mir helfen, da ich nicht mit Funktionen PHP vertraut bin.

Dank Alle

Rob

+0

'$ this -> _ createPass' Sie versuchen, Funktion' _createPass' in der Klasse 'Pass' zu nennen, aber du hast nicht die Funktion definiert in Ihrer Klasse – nospor

+0

Da Ihre 'Pass' Klasse keine Methode namens' _createPass() 'hat, ist das nicht wirklich überraschend –

Antwort

1

Die Funktion createPass fehlt.

Sie brauchen etwas wie folgt aus:

 /** 
    * Prepares the values and image for the pass and creates it 
    * 
    * @param string $resource Resource URL for the pass creation 
    * @param array $values Values 
    * @param array $images Images 
    * @return object Pass 
    */ 
    private function _createPass($resource, $values, $images) 
    { 
     $multipart = count($images) > 0; 
     if ($multipart) { 
      $content = array(); 
      foreach ($images as $imageType => $image) { 
       $this->_addImage($image, $imageType, $content, $imageType); 
      } 
      var_dump($content); 
      // Write json to file for curl 
      $jsonPath = array_search('uri', @array_flip(stream_get_meta_data(tmpfile()))); 
      file_put_contents($jsonPath, json_encode($values)); 
      $content['values'] = sprintf('@%s;type=application/json', $jsonPath); 
     } else { 
      $content = $values; 
     } 
     return $this->_restCall('POST', $resource, $content, $multipart); 
    } 

..And full script here

+0

Hallo @Dumkaa jetzt bekomme ich Undefinierte Methode mit _restCall. Ich habe versucht, dieses SDK zu verwenden, aber bin damit verloren –

+0

@ Renegade-Rob _restCall Funktion in 660 Zeile dieser [Datei] gefunden (https://github.com/passslot/passslot-php-sdk/blob/master/ src/PassSlot.php # L660) – Dumkaaa

Verwandte Themen