Hey all, I am busy porting the Vimeo PHP library
https://github.com/vimeo/vimeo-php-lib into ColdFusion and have successfully been able to handle almost everything except the video upload POST request. The PHP lib uses cURL like this:
$params = array(
'oauth_consumer_key' => $this->_consumer_key,
'oauth_token' => $this->_token,
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => time(),
'oauth_nonce' => $this->_generateNonce(),
'oauth_version' => '1.0',
'ticket_id' => $ticket,
'chunk_id' => $i
);
// Generate the OAuth signature
$params = array_merge($params, array(
'oauth_signature' => $this->_generateSignature($params, 'POST', self::API_REST_URL),
'file_data' => '@'.$chunk['file'] // don't include the file in the signature
));
// Post the file
$curl = curl_init($endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
$rsp = curl_exec($curl);
curl_close($curl);
I am trying to reproduce this functionality in ColdFusion without the use of any third party libraries. However, I can also dip down into Java if needed. Here's what I have so far:
var queryParams = {
"oauth_consumer_key" = variables.consumerKey,
"oauth_token" = variables.token,
"oauth_signature_method" = "HMAC-SHA1",
"oauth_timestamp" = _getUnixTime(),
"oauth_nonce" = _generateNonce(),
"oauth_version" = "1.0",
"ticket_id" = ticket,
"chunk_id" = (i - 1)
};
// Generate the OAuth signature
queryParams["oauth_signature"] = _generateSignature(queryParams);
queryParams["file_data"] = chunks[i]["file"]; // don't include the file in the signature
// Post the file
var httpService = new Http();
httpService.setMethod("POST");
httpService.setUrl(endpoint);
var file = fileReadBinary(queryParams[key]);
for (key in queryParams) {
if (key == "file_data") {
httpService.addParam(type="file", name=key, value=fileReadBinary(queryParams[key]));
} else {
httpService.addParam(type="formfield", name=key, value=queryParams[key]);
}
}
but I realize I need to do something a little different in order to send the file. Any help on this would be greatly appreciated, and once this is done, hopefully we can have a working Vimeo library for the ColdFusion community. Finally, here are some links I've found helpful while researching this:
http://vimeo.com/api/docs/upload
http://stackoverflow.com/questions/3443564/translate-php-put-http-request-to-coldfusion