简体   繁体   English

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

[英]Unable to upload photo to Instagram with InstagramAPISharp UploadPhotoAsync() method

I'm trying to upload a photo from my pc to my instagram page but it keeps giving me a "ProcessingFailedError".我正在尝试将照片从我的电脑上传到我的 Instagram 页面,但它一直给我一个“ProcessingFailedError”。

Heres all the code I'm using to try and upload.这是我用来尝试上传的所有代码。 Its meant to be a small program.它的意思是一个小程序。 Heres the Github for the API: https://github.com/ramtinak/InstagramApiSharp继承人 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;
        }

The Exact Error:确切的错误:

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"}}

I don't know if you're still looking for an answer to this question, but I had the same problem and the solution was:我不知道你是否还在寻找这个问题的答案,但我遇到了同样的问题,解决方案是:

  1. The Instagram account you're publishing has to be an Instagram Business Account (which is pretty easy to switch your account to)您发布的 Instagram 帐户必须是 Instagram 商业帐户(很容易将您的帐户切换到该帐户)

  2. You can only upload.jpeg files.您只能上传.jpeg 文件。 Any other filetype will give a "Request processing failed" error.任何其他文件类型都会给出“请求处理失败”错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM