无法使用 InstagramAPISharp UploadPhotoAsync() 方法将照片上传到 Instagram
Unable to upload photo to Instagram with InstagramAPISharp UploadPhotoAsync() method
我正在尝试将照片从我的电脑上传到我的 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;
}
确切错误:
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"}}
我不知道你是否还在寻找这个问题的答案,但我遇到了同样的问题,解决方案是:
您要发布的 Instagram 帐户必须是 Instagram 企业帐户(很容易将您的帐户切换到)
您只能上传 .jpeg 文件。任何其他文件类型都会给出“请求处理失败”错误。
我正在尝试将照片从我的电脑上传到我的 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;
}
确切错误:
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"}}
我不知道你是否还在寻找这个问题的答案,但我遇到了同样的问题,解决方案是:
您要发布的 Instagram 帐户必须是 Instagram 企业帐户(很容易将您的帐户切换到)
您只能上传 .jpeg 文件。任何其他文件类型都会给出“请求处理失败”错误。