我正在尝试使用发送传真的API。发送文件到API - C#
我有以下PHP例子: (我将然而使用C#)
<?php
//This is example code to send a FAX from the command line using the Simwood API
//It is illustrative only and should not be used without the addition of error checking etc.
$ch = curl_init("http://url-to-api-endpoint");
$fax_variables=array(
'user'=> 'test',
'password'=> 'test',
'sendat' => '2050-01-01 01:00',
'priority'=> 10,
'output'=> 'json',
'to[0]' => '44123456789',
'to[1]' => '44123456780',
'file[0]'=>'@/tmp/myfirstfile.pdf',
'file[1]' => '@/tmp/mysecondfile.pdf'
);
print_r($fax_variables);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fax_variables);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec ($ch);
$info = curl_getinfo($ch);
$result['http_code'];
curl_close ($ch);
print_r($result);
?>
我的问题是 - 在C#世界,我怎么会达到同样的效果?
我是否需要构建发布请求?
理想的情况下,我试图做到这一点使用REST - 和构造URL,并且使用的HttpWebRequest(GET)调用API,你要发送的数据,你应该使用POST
好的谢谢,那么我应该如何在C#中做到这一点? – Alex 2010-05-17 16:51:53