首页 > 解决方案 > 我如何使用 php https://www.fembed.com/api#download-video 使用 curl -X POST api

问题描述

我正在尝试使用https://www.fembed.com/api#transfer-video中的这个 api,有人可以详细说明如何使用 php 使用它,我知道如何使用 curl -X POST。

-d "client_id=ClIENT_ID&client_secret=ClIENT_SECRET"
-d "links=JSON_ENCODED_ARRAY"
-H "Content-Type: application/x-www-form-urlencoded"```

can someone help me and give me an example please

标签: phpcurl

解决方案


您必须使用 php-curl 进行设置

php-curl 手册

这里是参数:

卷曲参数

用你的数据做这个卷曲:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://url-to-send-post'); 
curl_setopt($ch, CURLOPT_HEADER, TRUE); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"client_id=ClIENT_ID&client_secret=ClIENT_SECRET&file_id=IdOfVideo&title=NEW_TITLE");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 

$data = curl_exec($ch); 
curl_close($ch);

var_dump($data);//response data

推荐阅读