通过Google Play服务发布API上传成就图标

问题描述

我正在寻找一种解决方案,可以通过脚本从json设置中设置Google Play应用的成就。

目前,我可以插入新成就,但是我无法上传成就图标。

这是我尝试使用C#


var applicationId = "MY_APPLICATION_ID"
var service = new GamesConfigurationService(new BaseClientService.Initializer
{
    HttpClientInitializer = credential,// use O-Auth 2.0
});        
var resources = new AchievementConfigurationsResource(service);
var newData = new AchievementConfiguration
{
    AchievementType = @"STANDARD",InitialState = @"REVEALED",Draft = new AchievementConfigurationDetail
    {
        Name = new LocalizedStringBundle
        {
            Translations = new List<LocalizedString>
            {
                new LocalizedString
                {
                    Locale = "en-US",Value = "Test7"
                }
            }
        },PointValue = 5,},};
var response = await resources.Insert(newData,applicationId).ExecuteAsync(); // new achievement is inserted!

var imageResources = new ImageConfigurationsResource(service);
if (File.Exists("Assets/Bronze_Other.png") == false)
{
    Debug.Log("Not Exists");
}
FileStream file = new FileStream("Assets/Bronze_Other.png",FileMode.Open);
var imageType = @"image/png";

var imageRequest = imageResources.Upload(applicationId,ImageConfigurationsResource.UploadRequest.ImageTypeEnum.ACHIEVEMENTICON);
var imageUpload = await imageRequest.ExecuteAsync(); // return 404

// even if I sucessfully uploaded,how to link it with specific achievement???

这将导致错误

</style>\n <a href=//www.google.com/> <span id=logo aria-label=Google></span></a>\n <p><b>404.</b> <ins>That’s an
        error.</ins>\n <p>The requested URL
        <code>/upload/games/v1configuration/images/MY_APPLICATION_ID/imageType/ACHIEVEMENT_ICON</code> was not found on this
        server. <ins>That’s all we know.</ins>\n\r\n at Google.Apis.Upload.ResumableUpload`1+<InitiateSessionAsync>
            d__25[TRequest].MoveNext () [0x000dc] in
            C:\\Apiary\\2020-08-17.16-07-28\\Src\\Support\\Google.Apis\\Upload\\ResumableUpload.cs:1127 \r\n--- End of
            stack trace from previous location where exception was thrown ---\r\n at
            System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in
            <fb001e01371b4adca20013e0ac763896>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
                (System.Threading.Tasks.Task task) [0x0003e] in <fb001e01371b4adca20013e0ac763896>:0 \r\n at
                    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
                    (System.Threading.Tasks.Task task) [0x00028] in <fb001e01371b4adca20013e0ac763896>:0 \r\n at
                        System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task)
                        [0x00008] in <fb001e01371b4adca20013e0ac763896>:0 \r\n at
                            System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult
                            () [0x00000] in <fb001e01371b4adca20013e0ac763896>:0 \r\n at
                                Google.Apis.Upload.ResumableUpload+<UploadAsync>d__67.MoveNext () [0x0004f] in
                                    C:\\Apiary\\2020-08-17.16-07-28\\Src\\Support\\Google.Apis\\Upload\\ResumableUpload.cs:411
                                    "

我已确认图像文件确实存在,图像格式和分辨率有效,并且通过了O-Auth(我使用其他API进行了测试)

documentation中的“ resourceID”一词令人困惑,因此我选择了here中已弃用的仓库中提到的应用程序ID。

欢迎使用任何其他语言的解决方案,谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...