1

Google マップの PHP クライアントが正しく動作するように作業を進めています。

GitHub:https://github.com/google/google-api-php-clientから GoogleAPI PHP クライアントのローカル コピーをダウンロードしました。

IIS8 で PHP v5.4 を実行しています。GoogleAPI は、 GoogleAPIの下の PHP Include フォルダーにインストールされました。

PHP は、他のすべてのスクリプトで正しく動作します。

Maps-Engine Documentationからサンプルを動作させようとしています。

<?php
ini_set('display_errors','on');

require('GoogleAPI/autoload.php');

//require_once 'GoogleAPI/src/Google/Client.php';
//require_once 'Google/Service/MapsEngine.php';

$apiKey = "API Key";

$client = new Google_Client();
$client->setApplicationName("Google-PhpMapsEngineSample/1.0");
$client->setDeveloperKey($apiKey);

$service = new Google_Service_MapsEngine($client);

$optParams = array('maxResults' => 500, 'version' => 'published');
$results = $service->tables_features->listTablesFeatures("12421761926155747447-06672618218968397709", $optParams);

print_r($results);

?>
コード例の唯一の変更点は、API キー、Google Autoloader の読み込み、require_once ディレクティブのコメント アウトです。

私が受け取る出力は次のとおりです。

Fatal error: Class 'Google_Service_MapsEngine_MapItem' not found in C:\Program Files (x86)\PHP\v5.4\includes\GoogleAPI\src\Google\Service\MapsEngine.php on line 4702

MapsEngine:4702 は Google_Service_MapsEngine_MapItem クラスを拡張します。Google_Service_MapsEngine_MapItem クラスは、Model.php ファイルで定義された Google_Model クラスを拡張します。

4

1 に答える 1

2

こんにちは私は同じ問題を抱えていました。

google-api-php-client/src/Google/Service/MapsEngine.php ファイルにバグがあります。Google_Service_MapsEngine_MapItem クラスを拡張するクラス Google_Service_MapsEngine_MapFolder は、クラス Google_Service_MapsEngine_MapItem が宣言される前に宣言されます。

MapsEngine.php ファイル内の 2 つのクラスの順序を入れ替えると、問題が解決しました。これは、クラスの正しい順序を示しています。

class Google_Service_MapsEngine_MapItem extends Google_Model
{
  protected $internal_gapi_mappings = array(
  );
  public $type;


  public function setType($type)
  {
    $this->type = $type;
  }
  public function getType()
  {
    return $this->type;
  }
}

class Google_Service_MapsEngine_MapFolder extends Google_Service_MapsEngine_MapItem
{
  protected $collection_key = 'defaultViewport';
  protected $internal_gapi_mappings = array(
  );
  protected $contentsType = 'Google_Service_MapsEngine_MapItem';
  protected $contentsDataType = 'array';
  public $defaultViewport;
  public $expandable;
  public $key;
  public $name;
  public $visibility;
  protected function gapiInit()
  {
    $this->type = 'folder';
  }

  public function setContents($contents)
  {
    $this->contents = $contents;
  }
  public function getContents()
  {
    return $this->contents;
  }
  public function setDefaultViewport($defaultViewport)
  {
    $this->defaultViewport = $defaultViewport;
  }
  public function getDefaultViewport()
  {
    return $this->defaultViewport;
  }
  public function setExpandable($expandable)
  {
    $this->expandable = $expandable;
  }
  public function getExpandable()
  {
    return $this->expandable;
  }
  public function setKey($key)
  {
    $this->key = $key;
  }
  public function getKey()
  {
    return $this->key;
  }
  public function setName($name)
  {
    $this->name = $name;
  }
  public function getName()
  {
    return $this->name;
  }
  public function setVisibility($visibility)
  {
    $this->visibility = $visibility;
  }
  public function getVisibility()
  {
    return $this->visibility;
  }
}
于 2015-01-20T17:23:39.630 に答える