普通网友 2019-06-11 20:25
浏览 26

对Mixcloud的POST请求

I have a PHP script that POSTs to Mixcloud and receiving an error I have not been able to resolve.

This is using PHP 7.3.6 and curl as I've seen in other posts as example.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.mixcloud.com/upload/?access_token=$mixcloud");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60 * 10);
curl_setopt($ch, CURLOPT_NOPROGRESS, true);
$server_output = curl_exec($ch);
curl_close ($ch);
// load json response into array
$res = json_decode($server_output, true);
echo print_r( $post, true );
echo print_r($res, true);

The upload fails with the following post that was sent:

Array
(
    [mp3] => @/var/share_ro/fullshow/surface.mp3
    [name] => Upload title
    [description] => Upload description
    [picture] => @/var/share_ro/fullshow/avatar.png
    [tags-0-tag] => Tag1
    [tags-1-tag] => Tag2
    [tags-2-tag] => Tag3
    [tags-3-tag] => Tag4
    [tags-4-tag] => Tag5
)

and response:

Array
(
    [details] => Array
        (
            [mp3] => Array
                (
                    [0] => This field is required.
                )

        )

    [error] => Array
        (
            [message] =>
            [type] => PostValidationError
        )

)

However, the full path to the file does exist and I have tried with and without the leading @ on the file name:

$ ls -lah /var/share_ro/fullshow/surface.mp3
-rw-r--r-- 1 user mp3 79M Jun 11 16:08 /var/share_ro/fullshow/surface.mp3

Can someone see what it is I'm doing wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等