using encoding.com to transcode an uploaded video - once this works, I will populate the source with the path to the CCK video that is uploaded
the script works fine when run from Devel Execute PHP
the trigger (Content is Saved) is happening, I get a custom screen message set as an an action with greater wheight than custom PHP
(xxxx blanks out sensitive fields)
function sendRequest($xml)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://manage.encoding.com/");
curl_setopt($ch, CURLOPT_POSTFIELDS, "xml=" . urlencode($xml));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
return curl_exec($ch);
}
// Preparing XML request
// Main fields
$req = new SimpleXMLElement('<?xml version="1.0"?><query></query>');
$req->addChild('userid', 'xxxx');
$req->addChild('userkey', 'xxxx');
$req->addChild('action', 'AddMedia');
//source
$req->addChild('source', 'http://xxxx/sites/default/files/videostmp/bear.flv');
$lastslash = strripos($req->source,'/') + 1;
$flv = substr($req->source,$lastslash).".flv";
$jpg = substr($req->source,$lastslash).".jpg";
//notification method
$req->addChild('notify', "xxxx");
//video format attributes
$video = $req->addChild('format');
$video->addChild('output', "flv"); //output filetype
$video->addChild('destination', 'ftp://xxxx/www/sites/default/files/transcoded/'. $flv); //output destination
$video->addChild('size','320x240'); //size
$video->addChild('bitrate','256k'); //bitrate
$video->addChild('audio_bitrate','64k'); //audio bitrate
$video->addChild('audio_sample_rate','44100'); //audio sampling rate
$video->addChild('audio_channels_number','2'); //audio channels
$video->addChild('framerate','15'); //frame rate
$video->addChild('two_pass','no'); //use two-pass?
$video->addChild('cbr','no'); //use constant bit rate?
$video->addChild('deinterlacing','no'); //use deinterlacing?
$video->addChild('add_meta','no'); //add meta data?
$logo = $video->addChild('logo');
$logo->addChild('logo_source', 'xxxx.png');
$logo->addChild('logo_x', '0');
$logo->addChild('logo_y', '0');
$logo->addChild('logo_mode', '0');
$logo->addChild('logo_threshold', 'ff0000');
$thumb = $req->addChild('format');
$thumb->addChild('output', 'thumbnail');
$thumb->addChild('time', '3');
$thumb->addChild('width', '160');
$thumb->addChild('height', '112');
$thumb->addChild('destination', 'ftp://xxxx:xxxx@xxxx/www/sites/default/files/transcoded/'. $jpg);
// Sending API request
$res = sendRequest($req->asXML());
exit;
Comments
Comment #1
decibel.places commenteddid a little more tshooting - confirmed that basic PHP code works in custom box
so I set a $_SESSION var and added to it each step of the cURL and I did not even record the first step, declaring the sendRequest function
I also thought that var names might be conflicting, I prepended a short string to all the vars
still not working in Rules Custom PHP, still working in Devel Execute PHP with same code
Comment #2
cindyr commentedAny ideas? I just stumbled across the same problem tonight...
Comment #3
cindyr commentedHope this will help debug...
Here's my custom PHP:
And here are the errors I'm getting now:
Warning: curl_setopt(): supplied argument is not a valid cURL handle resource in /usr/www/.../sites/all/modules/rules/rules/modules/php.rules.inc(107) : eval()'d code on line 2
Warning: curl_exec(): supplied argument is not a valid cURL handle resource in /usr/www/.../sites/all/modules/rules/rules/modules/php.rules.inc(107) : eval()'d code on line 3
Comment #4
decibel.places commented@cindyr
what I did to work around it is:
1. set the filename fid filepath etc as session cookies in Rules
2. then use Rules to redirect to a fully themed page containing the PHP cURL script passing it the values
(it didn't work so well on a standalone script file, but putting the PHP into a node works)
alternatively, I suppose you could set the form's action to the script page and bypass Rules, but Rules' conditions checking etc is useful
Comment #5
mitchell commentedThis issue may help with this project.
Comment #6
twistor commentedHopefully it helped.