1

你好你好吗?我正在尝试使用 FaxOut API:

http://service.ringcentral.com/faxoutapi/

这就是关于 api 的全部文档。基本上我需要发送一个带有一些数据的 HTTP POST。

这是我的代码,但我无法让它工作,请告诉我是否有我没有看到的东西。

string URLAuth = "https://service.ringcentral.com/faxapi.asp";
WebClient webClient = new WebClient();
var formData = new NameValueCollection();
formData["Username"] = "2487955151";
formData["Password"] = "mypassword";
formData["Recipient"] = "12485974888";
formData["Coverpagetext"] = "Some random text";
formData["Resolution"] = "High";
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);
string resultAuthTicket = Encoding.UTF8.GetString(responseBytes);
webClient.Dispose();

return resultAuthTicket;

非常感谢!

4

3 回答 3

0

我已经集成了 Popfax 服务,该服务还提供传真 API http://www.popfax.com/index.php?pop=corporate&corp=free_api它与我们的应用程序完美配合。我相信它也会与您的软件一起使用。唯一的条件是要有清晰的代码。

于 2013-09-11T13:39:32.393 回答
0

您的代码可能无法正常工作,因为WebClient.UploadValues()可能会创建和发送内容类型设置为的请求,application/x-www-form-urlencoded而 API 需要multipart/form-data. multipart/form-data是发送文件时流行的内容类型。

这是一些使用System.Net.Http(and System.IO) 发送multipart/form-data请求的工作 C# 代码。

string url = "https://service.ringcentral.com/faxapi.asp";

var data = new MultipartFormDataContent();
data.Add(new StringContent("16501112222"), "username");
data.Add(new StringContent("mypassword"), "password");
data.Add(new StringContent("16501113333"), "recipient");
data.Add(new StringContent("RingCentral FaxOut API using C#"), "coverpagetext");
data.Add(new ByteArrayContent(File.ReadAllBytes("C:\\path\\to\\test.pdf", "attachment", "test.pdf");

var client = new HttpClient();
var response = client.PostAsync(new Uri(url), data).Result;
if (response.IsSuccessStatusCode)
{
    var responseContent = response.Content;
    var responseString = responseContent.ReadAsStringAsync().Result;
    Console.WriteLine(responseString);
}

您还可以使用涵盖传真等的更广泛的RingCentral Platform API 。

于 2015-06-22T08:27:58.740 回答
0

使用 ncToolControls ASP.NET

.aspx:

<%@ Register Assembly="ncToolControls" Namespace="ncToolControls" TagPrefix="nc" %>

<nc:FaxService ID="fsCtrl" AddCloseButton="true" CssClass="mobilestyle_input" Width="620px" runat="server" />  
<p align="center"><asp:Literal ID="lit_Message" runat="server"></asp:Literal></p>              

代码隐藏 .cs

protected void Page_Init(object sender, EventArgs e)
{
    this.fsCtrl.btnCloseFax.Click += new EventHandler(btnCloseFaxScreen_Click);
}
protected void Page_Load(object sender, EventArgs e)
{

    this.fsCtrl.eFaxServer_Name = "rcfax.com";
    this.fsCtrl.Host_Server_Name = "smtp.domain.com";
    this.fsCtrl.Assiged_Email = "Authenticated Email Goes Here";
    this.fsCtrl.AssigedEmail_Password = "Password Goes Here";        
    this.fsCtrl.HostServer_PortNumber = 25;
    this.fsCtrl.HostServerRequireAuthentication = false;
    this.fsCtrl.HostServerRequireSSL = false;
    this.fsCtrl.HostServerRequiresInternationalDigit = false;
    this.fsCtrl.Company_FaxNumber = "12125555555";
    this.fsCtrl.FaxOut_FolderPath = "~/faxout/";  //- Folder must be valid path in Virtual Directory


    if (!Page.IsPostBack)
    {

    }
    btnSave_Click(sender, e);                
}

在此处下载示例和控制 http://www.netstair.net/download/RingCentral-Fax.zip

于 2016-04-10T15:39:58.960 回答