Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Port Vimeo Upload PHP POST Request to ColdFusion

69 views
Skip to first unread message

Greg Stallings

unread,
Apr 23, 2012, 12:36:54 PM4/23/12
to
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

Wilco

unread,
Oct 21, 2013, 9:59:42 AM10/21/13
to
Hey Greg,

Your post has been a while. I'm currently looking for a script to upload video's to vimeo in Coldfusion. Were you able to successfully complete your rewrite of vimeo php lib to coldfusion? I'm curious if there is already a Vimeo library for Coldfusion available. I'm looking around but i cant find much information about it.


Op maandag 23 april 2012 18:36:54 UTC+2 schreef Greg Stallings:
0 new messages