PHP:在Google Play开发者API中调用未定义的方法

PHP:在Google Play开发者API中调用未定义的方法,php,google-api,google-api-php-client,google-play-developer-api,Php,Google Api,Google Api Php Client,Google Play Developer Api,我将通过远程服务器上的PHP客户端,使用GoogleAPI获取我的应用内产品列表 这是我的密码: $client = new Google_Client(); $client->setClientId($client_id); $client->setClientSecret($client_secret); $client->setRedirectUri($redirect_uri); $client->addScope("https://www.googleapis.

我将通过远程服务器上的PHP客户端,使用GoogleAPI获取我的应用内产品列表

这是我的密码:

$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("https://www.googleapis.com/auth/androidpublisher");

$service = new Google_Service_AndroidPublisher($client);
$optParams = array('token' => 'my token....');
$results = $service->inappproducts->list ('my.package.name', $optParams);
当我运行此代码时,出现以下错误:
致命错误:调用未定义的方法Google\u Service\u AndroidPublisher\u inapproducts\u Resource::list()

我根据中列出的一些示例和详细信息实现了我的代码。我刚刚带来了
$service->inapproducts
的var_dump供您参考:

object(Google_Service_AndroidPublisher_Inappproducts_Resource)#14 (7) { ["stackParameters":"Google_Service_Resource":private]=> array(10) { ["alt"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } ["fields"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } ["trace"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } ["userIp"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } ["quotaUser"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } ["data"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(4) "body" } ["mimeType"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(6) "header" } ["uploadType"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } ["mediaUpload"]=> array(2) { ["type"]=> string(7) "complex" ["location"]=> string(5) "query" } ["prettyPrint"]=> array(2) { ["type"]=> string(6) "string" ["location"]=> string(5) "query" } } ["rootUrl":"Google_Service_Resource":private]=> string(27) "https://www.googleapis.com/" ["client":"Google_Service_Resource":private]=> object(Google_Client)#1 (9) { ["auth":"Google_Client":private]=> NULL ["io":"Google_Client":private]=> NULL ["cache":"Google_Client":private]=> NULL ["config":"Google_Client":private]=> object(Google_Config)#2 (1) { ["configuration":protected]=> array(7) { ["application_name"]=> string(0) "" ["auth_class"]=> string(18) "Google_Auth_OAuth2" ["io_class"]=> string(14) "Google_IO_Curl" ["cache_class"]=> string(17) "Google_Cache_File" ["logger_class"]=> string(18) "Google_Logger_Null" ["base_path"]=> string(26) "https://www.googleapis.com" ["classes"]=> array(10) { ["Google_IO_Abstract"]=> array(1) { ["request_timeout_seconds"]=> int(100) } ["Google_IO_Curl"]=> array(2) { ["disable_proxy_workaround"]=> bool(false) ["options"]=> NULL } ["Google_Logger_Abstract"]=> array(4) { ["level"]=> string(5) "debug" ["log_format"]=> string(42) "[%datetime%] %level%: %message% %context% " ["date_format"]=> string(13) "d/M/Y:H:i:s O" ["allow_newlines"]=> bool(true) } ["Google_Logger_File"]=> array(3) { ["file"]=> string(12) "php://stdout" ["mode"]=> int(416) ["lock"]=> bool(false) } ["Google_Http_Request"]=> array(2) { ["disable_gzip"]=> bool(false) ["enable_gzip_for_uploads"]=> bool(false) } ["Google_Auth_OAuth2"]=> array(13) { ["client_id"]=> string(71) "" ["client_secret"]=> string(24) "" ["redirect_uri"]=> string(42) "https://android-e1test.rhcloud.com/verify/" ["developer_key"]=> string(0) "" ["hd"]=> string(0) "" ["prompt"]=> string(0) "" ["openid.realm"]=> string(0) "" ["include_granted_scopes"]=> string(0) "" ["login_hint"]=> string(0) "" ["request_visible_actions"]=> string(0) "" ["access_type"]=> string(6) "online" ["approval_prompt"]=> string(4) "auto" ["federated_signon_certs_url"]=> string(42) "https://www.googleapis.com/oauth2/v1/certs" } ["Google_Task_Runner"]=> array(5) { ["initial_delay"]=> int(1) ["max_delay"]=> int(60) ["factor"]=> int(2) ["jitter"]=> float(0.5) ["retries"]=> int(0) } ["Google_Service_Exception"]=> array(1) { ["retry_map"]=> array(4) { [500]=> int(-1) [503]=> int(-1) ["rateLimitExceeded"]=> int(-1) ["userRateLimitExceeded"]=> int(-1) } } ["Google_IO_Exception"]=> array(1) { ["retry_map"]=> array(5) { [6]=> int(-1) [7]=> int(-1) [28]=> int(-1) [35]=> int(-1) [52]=> int(-1) } } ["Google_Cache_File"]=> array(1) { ["directory"]=> string(18) "/tmp/Google_Client" } } } } ["logger":"Google_Client":private]=> NULL ["deferExecution":"Google_Client":private]=> bool(false) ["requestedScopes":protected]=> array(1) { [0]=> string(48) "https://www.googleapis.com/auth/androidpublisher" } ["services":protected]=> array(0) { } ["authenticated":"Google_Client":private]=> bool(false) } ["serviceName":"Google_Service_Resource":private]=> string(16) "androidpublisher" ["servicePath":"Google_Service_Resource":private]=> string(33) "androidpublisher/v2/applications/" ["resourceName":"Google_Service_Resource":private]=> string(13) "inappproducts" ["methods":"Google_Service_Resource":private]=> array(7) { ["batch"]=> array(3) { ["path"]=> string(19) "inappproducts/batch" ["httpMethod"]=> string(4) "POST" ["parameters"]=> array(0) { } } ["delete"]=> array(3) { ["path"]=> string(33) "{packageName}/inappproducts/{sku}" ["httpMethod"]=> string(6) "DELETE" ["parameters"]=> array(2) { ["packageName"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["sku"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } } } ["get"]=> array(3) { ["path"]=> string(33) "{packageName}/inappproducts/{sku}" ["httpMethod"]=> string(3) "GET" ["parameters"]=> array(2) { ["packageName"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["sku"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } } } ["insert"]=> array(3) { ["path"]=> string(27) "{packageName}/inappproducts" ["httpMethod"]=> string(4) "POST" ["parameters"]=> array(2) { ["packageName"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["autoConvertMissingPrices"]=> array(2) { ["location"]=> string(5) "query" ["type"]=> string(7) "boolean" } } } ["list"]=> array(3) { ["path"]=> string(27) "{packageName}/inappproducts" ["httpMethod"]=> string(3) "GET" ["parameters"]=> array(4) { ["packageName"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["maxResults"]=> array(2) { ["location"]=> string(5) "query" ["type"]=> string(7) "integer" } ["startIndex"]=> array(2) { ["location"]=> string(5) "query" ["type"]=> string(7) "integer" } ["token"]=> array(2) { ["location"]=> string(5) "query" ["type"]=> string(6) "string" } } } ["patch"]=> array(3) { ["path"]=> string(33) "{packageName}/inappproducts/{sku}" ["httpMethod"]=> string(5) "PATCH" ["parameters"]=> array(3) { ["packageName"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["sku"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["autoConvertMissingPrices"]=> array(2) { ["location"]=> string(5) "query" ["type"]=> string(7) "boolean" } } } ["update"]=> array(3) { ["path"]=> string(33) "{packageName}/inappproducts/{sku}" ["httpMethod"]=> string(3) "PUT" ["parameters"]=> array(3) { ["packageName"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["sku"]=> array(3) { ["location"]=> string(4) "path" ["type"]=> string(6) "string" ["required"]=> bool(true) } ["autoConvertMissingPrices"]=> array(2) { ["location"]=> string(5) "query" ["type"]=> string(7) "boolean" } } } } } 

我是从臀部开始拍摄,但试试这个:

$results = $service->inappproducts->listInappproducts('my.package.name', $optParams);
而不是:

$results = $service->inappproducts->list ('my.package.name', $optParams);

正如我所评论的,你应该改变你的客户秘密,因为它看起来像是你在你的var_垃圾堆里发布的。

是的,我也在一条类似的船上。他们愚蠢的php客户端库没有任何文档,没有关于任何函数或类的信息,也没有关于你应该使用哪些函数或类来做什么的信息。现在可能要更改这些内容。@CaptainHypertext谢谢!在发布之前,我已经检查了var_dump,但是我错过了。您是根据php客户端的文档还是根据var_dump修复了它?它导致了新的异常:
Error:Uncaught异常“Google_Service_exception”,消息是“Error calling GET…”。。。。谷歌api php客户端/src/google/Http/REST.php:110中的“需要登录”,我通过查看谷歌php库源代码修复了它。我一直需要弄清楚方法名是
list()
还是
listables()
或其他什么(我正在使用gmail api)。但这似乎解决了问题。现在,根据错误消息,您的请求似乎失败了,因为Google希望您进行身份验证。也许会有帮助?