0

나는 access_token이 지금이 샘플을 사용하여 Google API에서 FATA를 얻을 시도 :API google에서 데이터를 가져 오는 방법은 무엇입니까?

https://developers.google.com/android-publisher/api-ref/edits/details/get

내가 데이터가이 URL에 쿼리를 실행 얻을하려고 :

https://www.googleapis.com/androidpublisher/v2/applications/packageName/edits/editId

$curl = new Curl(); 
    $curl->get('https://www.googleapis.com/androidpublisher/v1/applications/com.shazam.android&access_token='.$_SESSION['access_token']["access_token"]); 

을 여기서 $_SESSION['access_token']["access_token"]access_token

결과 메시지가 나타납니다 : Error: 404: HTTP/1.1 404 Not Found

API에서 정보를 얻으려면 어떻게해야합니까?

이 전체 URL 요청이 작동하지 않습니다되어

https://www.googleapis.com/androidpublisher/v2/applications/com.shazam.android/edits/1?access_token=ya29.Ci-5Azg5JoBiESM5cEzM3TQrP3SXHAFirFg0f-Fj83PxtrtINWQDe2L-3f5wP7oAtQ 

{ 
"error": { 
    "errors": [ 
    { 
    "domain": "global", 
    "reason": "insufficientPermissions", 
    "message": "Insufficient Permission" 
    } 
    ], 
    "code": 403, 
    "message": "Insufficient Permission" 
} 
} 

전체 코드는 다음과 같습니다

$curl = new Curl(); 
     $curl->get('https://www.googleapis.com/androidpublisher/v1/applications/com.shazam.android/edits/1/&access_token='.$_SESSION['access_token']["access_token"]); 
+0

당신의 GET 요청은 요청의 매개 변수에 마지막 누락 "편집/editId"https://developers.google.com/android-publisher/api-ref/edits/get – DaImTo

+0

이 매개 변수의 내용은 무엇입니까? – Gagama

+0

get 요청으로 올바르게 형식화 할 수 있습니까? ! = & – DaImTo

답변

0

: 나는 컬 요청을 만들려고

// Create the client object and set the authorization configuration 
// from the client_secretes.json you downloaded from the developer console. 
$client = new Google_Client(); 

$client->setAuthConfig(__DIR__ . '/client_secrets.json'); 
$client->addScope(Google_Service_Analytics::ANALYTICS_READONLY); 

// If the user has already authorized this app then get an access token 
// else redirect to ask the user to authorize access to Google Analytics. 
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { 
    // Set the access token on the client. 
    $client->setAccessToken($_SESSION['access_token']); 


    $curl = new Curl(); 
    $curl->get('https://www.googleapis.com/androidpublisher/v1/applications/com.shazam.android/edits/1/&access_token='.$_SESSION['access_token']["access_token"]); 

    if ($curl->error) { 
     echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n"; 
    } else { 
     echo 'Response:' . "\n"; 
     var_dump($curl->response); 
    } 

    // Create an authorized analytics service object. 
    //$analytics = new Google_Service_Analytics($client); 

    // Get the first view (profile) id for the authorized user. 
    //$profile = getFirstProfileId($analytics); 

    // Get the results from the Core Reporting API and print the results. 
    //$results = getResults($analytics, $profile); 
    //printResults($results); 
} else { 
    $redirect_uri = 'http://localhost/play/oauth2callback.php'; 
    header('Location: ' . $redirect_uri); 
} 

access_token을받은 후 음, 또 다른 가능한 오류 403 or Insufficient Permission의 원인은 사용중인 범위가 incorr입니다. 또는 액세스 토큰을 검색 할 때 필요한 범위를 요청하지 않았습니다. 따라서 사용중인 범위를 다시 확인하고 사용중인 개발 콘솔에서 모든 API를 활성화하십시오. 당신은 당신이 엔드 포인트에 access_token은 전달하여 요청한 스코프하는 확인할 수 있습니다

: 그것은 당신을 도울 수 있다면

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN

자세한 내용은 다음 관련 SO 문제의 해결책을 확인합니다.

관련 문제