2016-06-01 2 views
0

誰かが助けてくれますか?次のPHPスクリプトで致命的なエラーが発生します。身元不明のメソッドへの致命的なエラーコールの取得Pass :: _ createpass()

「未確認のメソッドPass :: _ createpass()」というエラーは、以下のコードの2番目の最後の行に関連しています。

<?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); 
    } 
} 

私は機能PHPに慣れていないので、誰かが私を助けてくれることを願っています。

おかげですべての

ロブ

+0

'$この - > _ createPass'あなたはPass''クラスに関数 '_createPass'を呼び出そうが、あなたは、その関数を定義されていませんでしたあなたのクラスでは – nospor

+0

'Pass'クラスに' _createPass() 'というメソッドがないので、これは本当に驚くことではありません –

答えて

1

createPassが欠落している機能。

あなたはこのようなものが必要:

 /** 
    * 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

こんにちは@Dumkaa _restCallで未定義メソッドを取得しています。このSDKを使用しようとしましたが、失われました –

+0

@ renegade-rob _restCall関数はこの[file](https://github.com/passslot/passslot-php-sdk/blob/master/)の660行にありますsrc/PassSlot.php#L660) – Dumkaaa

関連する問題