Я хочу обновить заголовок, краткое описание и полное описание моих приложений в консоли Google Developper.
Я не могу сделать это в PHP, я нашел несколько примеров в Python, но мне нужно в PHP.
Вот что я сделал до сих пор:
function updateListing($configFileJSON) {
echo "Updating Listings"."\n";
$packageName = 'com.mycompany.myapp';
$client = new Google_Client();
$client->setApplicationName($packageName);
$client->setClientId('100......usercontent.com');
$key = "Rdhmg......5_t";
$client->setClientSecret($key);
$client->setScopes(array('https://www.googleapis.com/auth/androidpublisher') );
try {
$service = new Google_Service_AndroidPublisher($client);
$app_edit = new Google_Service_AndroidPublisher_AppEdit();
$edits = $service->edits;
$edit_request = $edits->insert($packageName,$app_edit);
$edit = $edit_request->execute();
$editId = $edit->getId();
echo ("Created edit with id: $editId");
$listing = $service->listings;
$listing.setTitle("WWW");
$listing.setFullDescription("WWW");
$listing.setShortDescription("WWW");
// $listing.setVideo("WWW");
$updateListingsRequest = $edits->listings()->update($packageName,$editId,"af", $listing);
$updatedUsListing = $updateListingsRequest->execute();
echo("Created new AF app listing with title: " . $$updatedUsListing->getTitle());
} catch (Exception $e) {
var_dump( $e->getMessage() );
}
echo "ENDING"."\n";
}
Я знаю, что до сих пор не хватает некоторого кода, но до сих пор я получаю:
string(238) "{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
пример в Python:
def main(argv):
# Authenticate and construct service.
service, flags = sample_tools.init(
argv,
'androidpublisher',
'v2',
__doc__,
__file__, parents=[argparser],
scope='https://www.googleapis.com/auth/androidpublisher')
# Process flags and read their values.
package_name = flags.package_name
try:
edit_request = service.edits().insert(body={}, packageName=package_name)
result = edit_request.execute()
edit_id = result['id']
listing_response_us = service.edits().listings().update(
editId=edit_id, packageName=package_name, language='af',
body={'fullDescription': 'Dessert trunk truck',
'shortDescription': 'Bacon ipsum',
'title': 'App Title US'}).execute()
print ('Listing for language %s was updated.'
% listing_response_us['language'])
listing_response_gb = service.edits().listings().update(
editId=edit_id, packageName=package_name, language='am',
body={'fullDescription': 'Pudding boot lorry',
'shortDescription': 'Pancetta ipsum',
'title': 'App Title UK'}).execute()
print ('Listing for language %s was updated.'
% listing_response_gb['language'])
commit_request = service.edits().commit(
editId=edit_id, packageName=package_name).execute()
# print 'Edit "%s" has been committed' % (commit_request['id'])
except client.AccessTokenRefreshError:
print ('The credentials have been revoked or expired, please re-run the '
'application to re-authorize')
if __name__ == '__main__':
main(sys.argv)
что мне не хватает в части аутентификации? у кого-нибудь есть пример обновления списка приложений на PHP?
Спасибо