相关疑难解决方法(0)

在Perl中发出HTTP GET请求的最简单方法是什么?

我有一些用PHP编写的代码,用于使用我们简单的Web服务,我也想在Perl中为可能更喜欢该语言的用户提供这些代码.制作HTTP请求的最简单方法是什么?在PHP中,我可以在一行中完成file_get_contents().

这是我想要移植到Perl的整个代码:

/**
 * Makes a remote call to the our API, and returns the response
 * @param cmd {string} - command string ID
 * @param argsArray {array} - associative array of argument names and argument values
 * @return {array} - array of responses
 */
function callAPI( $cmd, $argsArray=array() )
{
   $apikey="MY_API_KEY";
   $secret="MY_SECRET";
   $apiurl="https://foobar.com/api";

   // timestamp this API was submitted (for security reasons)
   $epoch_time=time();

   //--- assemble argument array into string
   $query = "cmd=" .$cmd;
   foreach ($argsArray as $argName …
Run Code Online (Sandbox Code Playgroud)

perl web-services http

36
推荐指数
4
解决办法
7万
查看次数

标签 统计

http ×1

perl ×1

web-services ×1