我正在努力让谷歌地图的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);
?>
&#13;
我收到的输出是:
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类。
答案 0 :(得分:2)
嗨,我遇到了同样的问题。
google-api-php-client / src / Google / Service / MapsEngine.php文件中存在错误。在声明类Google_Service_MapsEngine_MapItem之前声明了释放Google_Service_MapsEngine_MapItem的类Google_Service_MapsEngine_MapFolder。
我在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;
}
}