本文介绍了Twilio总通话时长与计费分钟数不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在所附的图像中,7月份的总语音分钟为30分钟.但是,如果我提取2014年7月同一月的通话记录(使用 https中的说明,请执行以下操作: //www.twilio.com/docs/api/rest/call ) ,我得到的总时长为17分钟. Log中的用法值和总呼叫持续时间值不应该相等吗?.

In the attached image , the total voice minutes for July is 30 minutes. However if I pull the call logs for the same month July 2014 (using the instruction in https://www.twilio.com/docs/api/rest/call) , I get total duration as 17 minutes. Shouldn't the value of usage and total call duration in Log be equal ?.

这是我的测试源代码,用于查找2014年7月的呼叫日志文件.非常感谢您的帮助.

Here is my test source code for finding the call log files for month July 2014. Any help is greatly appreciated.

       public static void  callLogs(string AccountSid, string AuthToken)
       {

        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var request = new CallListRequest();
        request.StartTimeComparison = ComparisonType.GreaterThanOrEqualTo;
        request.StartTime = new DateTime(2014, 07, 01);         
        request.EndTimeComparison = ComparisonType.LessThanOrEqualTo;
        request.EndTime = new DateTime(2014, 07, 31);
        var calls = twilio.ListCalls(request);

        int? voiceMinutes = 0;
        decimal? totalCost = 0;
        foreach (var call in calls.Calls)
        {

            if ( call.Price != null)
            {
                voiceMinutes += call.Duration;
                totalCost += call.Price ;
            }

            Console.WriteLine(call.Price  +"-" + call.DateCreated + "-" + call.From + "-" + call.To + "-" + call.Status + "-" + call.Duration  );
        }

        Console.WriteLine("Total Voice:" + int.Parse ((voiceMinutes/60).ToString() ));
        Console.WriteLine("Total Cost :" +  totalCost);
    }

推荐答案

对于计费分钟,Twilio将将所有电话四舍五入到最近的分钟.因此,您应该执行相同的操作.像这样:

For billing minutes, Twilio will round all calls up to the nearest minute. So you should do the same. Something like this:

voiceMinutes += (call.Duration + 60)/ 60;

然后:

Console.WriteLine("Total Voice:" + int.Parse ((voiceMinutes).ToString() ));

这篇关于Twilio总通话时长与计费分钟数不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 16:55