c# - C# InstaSharper:无法上传照片:解析值时遇到意外字符:S. Path '', line 0, position 0
问题描述
我将此库用作 instagram bot 程序的 NuGet 包(InstaSharper):https ://github.com/a-legotin/InstaSharper
在InsertImage();
函数中,该函数用于将照片上传到 Instagram 页面,在解析时,程序遇到问题并控制台返回:
登录!无法上传照片:解析值时遇到意外字符:S. Path '', line 0, position 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 下载它并在我的项目中使用它,它对我有用
希望这可以帮助
推荐阅读
- firebase - 如何通过最近在 Flutter 中添加的方式显示 Firestore 中的项目?
- oracle - Amazon EC2 中的 ODI 安装
- javascript - 如何通过 gRPC 通信发送/接收 JSON 文件?节点.js
- html - 使用标题参数 ImgHTMLAttributes React 标记 Src Image
- reactjs - React Actions 使用 RxJS 进行并行异步调用
- python - 如果索引相同,将行单元格移动到列
- python - 如何在 Flask 中使用单个 html 页面在我的选项卡中放置不同的路由?
- ubuntu - RPC 失败;curl 56 GnuTLS recv 错误(-9):解码接收到的 TLS 数据包时出错
- bash - bash 脚本变量 - 在脚本中有效,但在 cron 中无效
- gitlab-ci - 将文件从运行器主机复制到远程主机时,gitlab-ci ssh 远程命令随机挂起