リモート サーバーから PHP クライアントを使用して、Google 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リファレンスにリストされているいくつかのサンプルと詳細に基づいてコードを実装しました。$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" } } } } }