0

嘿,我找不到任何信息,但我想要实现的是使用 express/node rest API,它会使用 Dropbox JS SDK 将文件发送到不同的应用程序,主要是 PHP,这可能吗?我一直在玩弄它,不确定我是否在最好的道路上

API 代码

router.post('/', async (req, res) => {


    var dbx = new Dropbox({ accessToken: '<key>', fetch: fetch });
    dbx.filesDownload({path: "/large_vid.mp4"})
        .then(function (resp) {
            let data = resp[Object.keys(resp)[11]];
            res.status(201).send(data);
        })
        .catch(function (errs) {
            console.log(errs);
            res.status(203).send(errs);
        });
});


module.exports = router;

PHP 代码

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, $url);

      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
            'Content-Type: application/json',                                                                                
            'Content-Length: ' . strlen($postData))                                                                       
        );

      curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      $response = base64(curl_exec($ch));


4

0 回答 0