我的脸部版机器人有2200个订阅者,所以我使用以下代码每天向他们发送图像。但是,对于从bot框架
捕获的错误的大多数用户来说,此代码失败了 public static class MessagesSender
{
public static void SendSpecificMessage(string botName, string serviceURL, string botId, string messageCode, string messageText, string imageURL, Customer customer , Guid logId)
{
var connector = new ConnectorClient(new Uri(serviceURL));
Thread thread = new Thread(() => SendMessage(botName, serviceURL, botId, messageCode, messageText, imageURL, customer, connector , logId));
thread.Start();
}
private static void SendMessage(string botName, string serviceURL, string botId, string messageCode, string messageText, string imageURL, Customer customer, ConnectorClient connector , Guid logId)
{
try
{
Task.Run(async () =>
{
IMessageActivity message = Activity.CreateMessageActivity();
//defining accounts
var userAccount = new ChannelAccount(name: customer.name, id: customer.fromidstate);
var botAccount = new ChannelAccount(name: botName, id: botId);
//creating conversation
var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);
message.From = botAccount;
message.Recipient = userAccount;
message.Text = "Daily Image";
message.Conversation = new ConversationAccount(id: conversationId.Id.Replace("@", string.Empty));
if (!string.IsNullOrEmpty(imageURL))
{
message.Attachments = new List<Attachment>();
message.Attachments.Add(new Attachment()
{
ContentUrl = imageURL,
ContentType = "image"
});
}
await connector.Conversations.SendToConversationAsync((Activity)message);
}).Wait();
}
catch ( Exception ex)
{
throw ex;
}
}
}
{"error":{"message":"(#100) Failed to fetch the file from the url","type":"OAuthException","code":100,"error_subcode":2018008,"fbtrace_id":"G8ZFKZLCmNp"}}
我不知道该怎么做,因为当我发送一条消息时,它工作正常,但并非所有2200条消息都没有发送,如果我发送给10个人,那很好。而且主要的问题是文本被传递但不是图像
答案 0 :(得分:1)