2

私は、GoogleのAPIを使用してPHPのクライアントからリモートサーバーから自分のアプリ内アイテムのリストを取得します。PHP:Google PlayデベロッパーAPIで未定義のメソッドを呼び出す

は、ここに私のコードです:

$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); 

私は、私は次のエラーを取得するこのコードを実行すると: Fatal error: Call to undefined method Google_Service_AndroidPublisher_Inappproducts_Resource::list()

私はapi referenceに記載されているいくつかのサンプルや詳細に基づいて私のコードを実装しました。私はちょうどあなたの参照のため$service->inappproductsのの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" } } } } } 
+0

ええ、私は同じようなボートにいます。彼らの愚かなphpクライアントライブラリには、ゼロドキュメンテーション、機能やクラスに関する情報がなく、何をするために使用するはずのものがあります。 –

+0

あなたのクライアントIDとクライアントシークレットは、そのvarダンプにあります。今それらを変更したいかもしれません。 –

+0

@CaptainHypertextありがとう!私は投稿する前にvar_dumpをチェックしましたが、私はそれを逃しました。 – VSB

答えて

0

私はここに腰から撮影していますが、これを試してみてください。

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

の代わりに:

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

およびAS Iあなたがあなたのvar_dumpに投稿したように見えるので、クライアントの秘密を変更する必要があります。

+0

PHPクライアントのドキュメントやvar_dumpsに基づいて修正しましたか? – VSB

+0

新しい例外が発生しました: 'エラー:未知の例外' Google_Service_Exception '、「GET ....の呼び出しでエラーが発生しました」というメッセージが表示されるgoogle-api-php-client/src/Google/Http/REST.php:110 ' – VSB

+0

GoogleのPHPライブラリのソースコードを見て修正しました。メソッド名が 'list()'か 'listLables()'なのか、それともgmail apiを使っているのか分かりません。しかし、それは問題を解決したように見えます。今、エラーメッセージに基づいて、Googleが認証を求めているため、リクエストが失敗しているようです。おそらく[このリンク](https://github.com/google/google-api-php-client/issues/8)が役立ちますか? –

関連する問題