无法使用 InstagramAPISharp UploadPhotoAsync() 方法将照片上传到 Instagram

zai*_*bal 1 c# instagram instasharp instagram-api

我正在尝试将照片从我的电脑上传到我的 Instagram 页面,但它一直给我一个“ProcessingFailedError”。

这是我用来尝试上传的所有代码。它本来就是一个小程序。这是 API 的 Github: https: //github.com/ramtinak/InstagramApiSharp

using InstagramApiSharp;
using InstagramApiSharp.API;
using InstagramApiSharp.Classes;
using InstagramApiSharp.API.Builder;
using InstagramApiSharp.Logger;
using InstagramApiSharp.Classes.Models;

namespace HH_to_Insta
{
    class Program
    {
        public static UserSessionData userSession = new UserSessionData
        {
            UserName = "USERNAME",
            Password = "PASSWORD"
        };
        public static IInstaApi api = InstaApiBuilder.CreateBuilder()
                                        .SetUser(userSession)
                                        .UseLogger(new DebugLogger(LogLevel.All))
                                        .Build();

        static void Main(string[] args)
        {
            if (!Login().Result)
            {
                return;
            }

            var mediaImage = new InstaImageUpload
            {
                // leave zero, if you don't know how height and width is it.
                Height = 0,
                Width = 0,
                Uri = @"C:\Users\email\Desktop\Hardware Hub\logo data\instagram_profile_image.png"
            };

            api.MediaProcessor.UploadPhotoAsync(mediaImage, "Test Success!").Wait();
        }

        public static async Task<bool> Login()
        {
            if (!api.IsUserAuthenticated)
            {
                // login
                Console.WriteLine($"Logging in as {userSession.UserName}");
                var logInResult = await api.LoginAsync();
                if (!logInResult.Succeeded)
                {
                    Console.WriteLine($"Unable to login: {logInResult.Info.Message}");
                    return false;
                }
            }
            return true;
        }
Run Code Online (Sandbox Code Playgroud)

确切的错误:

1/17/2021 12:28:11 AM:  Response: POST https://i.instagram.com/rupload_igphoto/1610864891188_0_227063345 [BadRequest]
1/17/2021 12:28:11 AM:  Content:
1/17/2021 12:28:11 AM:  {"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"Request processing failed"}}

Run Code Online (Sandbox Code Playgroud)

小智 5

我不知道您是否还在寻找这个问题的答案,但我遇到了同样的问题,解决方案是:

  1. 您要发布的 Instagram 帐户必须是 Instagram 企业帐户(您可以很容易地将帐户切换到该帐户)

  2. 您只能上传 .jpeg 文件。任何其他文件类型都会给出“请求处理失败”错误。

  • 是的,这是因为我发布了 png 的。非常感谢你,我从来没有想过这一点。 (3认同)