我正在使用此库作为instagram机器人程序的NuGet包(InstaSharper):https://github.com/a-legotin/InstaSharper
[在InsertImage();
函数中,该函数用于将照片上传到instagram页面,而在解析时,程序遇到问题,并且控制台会返回:
已登录!无法上传照片:遇到意外字符解析值时:S.路径”,第0行,位置0。
我尝试使用不同的路径和图像类型,但是发生了相同的事情。
可能是什么问题以及如何解决?
这些是主要功能:
static void Main(string[] args)
{
user = new UserSessionData();
user.UserName = username;
user.Password = password;
Login();
Console.Read();
}
public static async void Login()
{
api = InstaApiBuilder.CreateBuilder().SetUser(user).UseLogger(new DebugLogger(LogLevel.Exceptions)).SetRequestDelay(RequestDelay.FromSeconds(1, 3)).Build();
var loginRequest = await api.LoginAsync();
if (loginRequest.Succeeded)
{
Console.WriteLine("Loged in!");
InsertImage(@"C:\test.jpg", "Testing");
}
else Console.WriteLine("Unable to log in: " + loginRequest.Info.Message);
}
public static async void InsertImage(string _path, string _caption)
{
var mediaImage = new InstaImage
{
Height = 1080,
Width = 1080,
URI = new Uri(Path.GetFullPath(_path), UriKind.Absolute).LocalPath
};
var result = await api.UploadPhotoAsync(mediaImage, _caption);
if (result.Succeeded == true) Console.WriteLine($"Media created: {result.Value.Pk}, {result.Value.Caption}");
else Console.WriteLine($"Unable to upload photo: {result.Info.Message}");
}
似乎InstaSharper Nuget软件包没有更新,我已经从Github下载了它,并在我的项目中使用了它,对我有用。
希望这会有所帮助
当前正在尝试相同的错误,如果您发现了如何解决该错误,请告诉这个不熟悉json和Web API开发技巧的同级suferer。>