小编CRA*_*AIG的帖子

LWP :: Protocol :: https未安装(如何安装?)

有人可以帮我吗?我创建了一个Perl脚本来运行https任务.当我运行它时,我得到错误LWP :: Protocol :: https未安装.

我无法弄清楚,或找到关于如何安装LWP :: Protocol :: http的教程或命令.任何人都知道如何安装它?安装LWP非常简单.

我已经安装了LWP并安装了Crypt-SSLeay,但我仍然收到错误.这是我的代码:

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;


# set custom HTTP request header fields

my $req = HTTP::Request->new(PUT => "https://thesite.com");

$req->header('Authorization' => 'myauth');
$req->header('Accept' => 'JSON:Application/JSON');
$req->header('Content-Type' => 'JSON:Application/JSON');
$req->header('Host' => 'api.thesite.com');

$req->content('Text' => 'thetext');



my $resp = $ua->request($req);
if ($resp->is_success) {
    my $message = $resp->decoded_content;
    print "Received reply: $message\n";
}
else {
    print "HTTP POST error code: ", $resp->code, "\n";
    print "HTTP POST error message: ", $resp->message, "\n";
} …
Run Code Online (Sandbox Code Playgroud)

perl lwp

12
推荐指数
2
解决办法
3万
查看次数

使用Curl和Oauth 2将DropBox API PUT上传到DropBox的示例

我到处搜索,找不到合适的例子,并且不够精通,无法通过文档对其进行排序.知道比我更多的人能告诉我如何为OAUTH 2形成CURL命令吗?是不是我只需要OAUTH 2密钥?我正在显示一个App密钥,app秘密和oauth 2.如果重要的话,我在perl脚本中使用它.

我找到的最接近的代码是:

 curl --request PUT --header "Content-Length: `ls -la jonathan.txt | awk '{ print $5}'`" --header         
 "Content-Type: multipart/mixed" --data-binary "@jonathan.txt" "https://api-    
 content.dropbox.com/1/files_put/dropbox/jonathan.txt?access_token=ABCDEF"
Run Code Online (Sandbox Code Playgroud)

但我不认为那是OAUTH 2吗?

curl dropbox oauth-2.0

8
推荐指数
2
解决办法
8604
查看次数

How to convert RGBA color codes to 8 Digit Hex in PHP?

I'm attempting to convert some rgba values into a format suitable for SubStation Alpha subtitle files. The .ass file format requires a colour format like &H12345690 where the hex bytes are in blue, green, red, alpha order.

I am finding examples converting 8 digit hex colors into RGBA, but not the other way around. Here is a function I put together based one of the answers, but the alpha channel is always returned as zero:

function rgbtohex($string) {
    $string …
Run Code Online (Sandbox Code Playgroud)

php colors subtitle rgba

1
推荐指数
1
解决办法
1598
查看次数

usort排序降序而不是升序超过2个阵列

合并4个数组后,我使用usort通过Date对最终数组进行排序.然而,它以升序的方式排序,我需要它是Descending.当只有2个数组被合并时,我已经看到了降序排序的解决方案,但是没有超过2个的例子.

每个数组($ files,$ newfiles,$ comments和$ ratings)都有以下字段:ID,Title,Date和Type.我需要通过Date Descending对它们进行排序.这是我目前的代码:

    function dateSort($a,$b,$c,$d){
$dateA = strtotime($a['Date']);
$dateB = strtotime($b['Date']);
$dateC = strtotime($c['Date']);
$dateD = strtotime($d['Date']);


 return ($dateA-$dateB-$dateC-$dateD);

  //I HAVE ALSO TRIED REVERSING THE ORDER LIKE THIS BUT NO LUCK.  
 //THE SORTING IS STRANGE AND UN ORDERED WHEN I DO THIS:
 // return ($dateD-$dateC-$dateB-$dateA);

 }

    $result = array_merge($files, $newfiles,$comments,$ratings);

    usort($result, 'dateSort');
Run Code Online (Sandbox Code Playgroud)

php usort

0
推荐指数
1
解决办法
4221
查看次数

标签 统计

php ×2

colors ×1

curl ×1

dropbox ×1

lwp ×1

oauth-2.0 ×1

perl ×1

rgba ×1

subtitle ×1

usort ×1