我试图通过json使用ajax和php curl包装完整的xml内容文件。
我在php中的定义如下:
$postData = array(
'api_key' => $this->access_key,
'task_store' => array(
'type' => 'volatile'
),
'tasks' => array(
'task_name' => 'video.create',
'preview' => true,
'definition' => $custom_definition // full path to my xml file
)
);
这不起作用。但是当我使用普通的xml(作为字符串)时,它可以工作:
$postData = array(
'api_key' => $this->access_key,
'task_store' => array(
'type' => 'volatile'
),
'tasks' => array(
'task_name' => 'video.create',
'preview' => true,
//'profile' => '1080p-24-fps',
'definition' => "<movie service=\"craftsman-1.0\"><body><stack duration=\"8\"><sequence><overlay duration=\"1\"><image color=\"#000000\" /></overlay><transition type=\"crossfade\" duration=\"1\"></transition><effect type=\"slice\" duration=\"2.5\" ><image filename=\"http://www.censier-publicinex.fr/wp-content/uploads/2012/07/Fotolia_25789474_Subscription_Monthly_XL1.jpg\"/></effect><effect type=\"slice\" duration=\"2.5\" ><image filename=\"http://www.censier-publicinex.fr/wp-content/uploads/2012/07/Fotolia_26368735_Subscription_Monthly_V.jpg\"/></effect><transition type=\"crossfade\" duration=\"1\"></transition><stack duration=\"4\"><stack><effect type=\"none\"><image filename=\"http://www.censier-publicinex.fr/wp-content/uploads/2012/07/Fotolia_23933407_Subscription_Monthly_XL.jpg\"/><filter type=\"gaussianBlur\" diameter=\"0.03\" ></filter></effect><overlay><image color=\"#000000\"><filter type=\"radialGradient\" color0=\"#ffffff\" color1=\"#000000\" point0=\"0.5,0.5\" point1=\"1,1\" ></filter><filter type=\"alpha\" alphaStart=\"0.5\" alphaEnd=\"0.5\" ></filter></image></overlay></stack><overlay duration=\"..\"><text type=\"advanced\" reference=\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAA \" align=\"center\" fontsize=\"17\" fontcolor=\"#333333\" face=\"arial\">Test</text><animator type=\"grow\" growEnd=\"0.2\"/><animator type=\"custom\"><key time=\"0.0\" pos=\"0,0.2,0\"/></animator></overlay></stack></sequence><overlay left=\"0\" bottom=\"0.07\" height=\"0.09\" width=\"1\"><image color=\"#ffffff\"/><filter type=\"alpha\" alphaStart=\"0.6\" alphaEnd=\"0.6\" /></overlay><text type=\"zone\" left=\"0\" bottom=\"0.07\" height=\"0.09\" fontcolor=\"#000000\" align=\"center,center\">kiki</text><!-- Mentions goes here --></stack> </body></movie>"
)
);
以下是整个方法:
public function generatePreview($custom_definition) {
/**
* Définit le service video.create et la définition xml utilisée
*/
$postData = array(
'api_key' => $this->access_key,
'task_store' => array(
'type' => 'volatile'
),
'tasks' => array(
'task_name' => 'video.create',
'preview' => true,
'definition' => $custom_definition
)
);
/**
* Initialise la connexion via cURL
*/
$ch = curl_init($this->host);
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization: Secret ' . $this->secret,
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_SSL_VERIFYPEER => false
));
/**
* Exécute la requête cURL
*/
$response = curl_exec($ch);
/**
* Vérifie s'il y a des erreurs dans la requête
*/
if($response === FALSE){
die(curl_error($ch));
}
else {
echo $response;
}
}
我也尝试使用file_get_contents()
功能,没有运气:它在文件图像中出现错误。
有人已经经历过这个吗?