1

トラックの説明を変更するスクリプト。404エラーが発生します。トークンとURLは有効です(コマンドラインから機能します)サンプル:

curl -X PUT "https://api.soundcloud.com/tracks/45272532.json" -F'oauth_token = 12345678' -F'track[description]=このトラックはベルリンで録音されました。

脚本:

#!/usr/bin/perl
use strict;
use warnings;
use WWW::Curl::Easy;
use WWW::Curl::Form;

my $curl = new WWW::Curl::Easy();
$curl->setopt( CURLOPT_VERBOSE,  1 );
$curl->setopt( CURLOPT_NOSIGNAL, 1 );
$curl->setopt( CURLOPT_HEADER,   1 );
$curl->setopt( CURLOPT_TIMEOUT,  10 );
$curl->setopt( CURLOPT_URL,      'https://api.soundcloud.com/tracks/45272532.json' );

my $curlf = new WWW::Curl::Form();
$curlf->formadd( 'oauth_token', 12345678' );
$curlf->formadd( 'track[description]', 'This track was recorded in Berlin.' );
$curl->setopt( CURLOPT_HTTPPOST, $curlf );

my $resp = '';
open( my $resp_fh, ">", \$resp );
$curl->setopt( CURLOPT_WRITEDATA, $resp_fh );

my $retcode = $curl->perform();
die($retcode) if ( $retcode != 0 );

print $resp;

応答:

* About to connect() to api.soundcloud.com port 443 (#0)
*   Trying 178.249.136.151... * connected
* Connected to api.soundcloud.com (178.249.136.151) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*    subject: C=DE; OU=Domain Control Validated; O=api.soundcloud.com; CN=api.soundcloud.com
*    start date: 2010-08-26 10:42:17 GMT
*    expire date: 2013-09-18 23:59:59 GMT
*    subjectAltName: api.soundcloud.com matched
*    issuer: C=BE; OU=Domain Validation CA; O=GlobalSign nv-sa; CN=GlobalSign Domain Validation CA
*    SSL certificate verify ok.
> POST /tracks/45272532.json HTTP/1.1
Host: api.soundcloud.com
Accept: */*
Content-Length: 319
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------5e3965475f60
< HTTP/1.1 100 Continue
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Sat, 05 May 2012 13:25:50 GMT
< Content-Type: application/xml; charset=utf-8
< Connection: keep-alive
< Cache-Control: no-cache
< X-Runtime: 8
< Access-Control-Allow-Methods: GET, PUT, POST, DELETE
< Access-Control-Allow-Headers: Accept, Authorization, Content-Type, Origin
< Access-Control-Allow-Origin: *
< X-Cacheable: NO:Cache-Control=no-cache
< Content-Length: 30
< X-Varnish: 1799105788
< Age: 0
< Via: 1.1 varnish
< X-Cache: MISS
< 
* Connection #0 to host api.soundcloud.com left intact
* Closing connection #0

ありがとうラデク

4

1 に答える 1

0
> POST /tracks/45272532.json HTTP/1.1

失敗します^^^^

$curl->setopt( CURLOPT_PUT,  1 );
于 2012-05-05T14:36:56.257 に答える