Alternatives to PEAR???

Subscribe to Alternatives to PEAR??? 3 posts, 2 voices

 
Avatar timh 4 posts

The hosted server I am on doesn’t have pear installed and getting it there isn’t likely to happen.

Are their other ways to generate http requests via PHP that don’t involve pear? I have heywatch working (by bouncing my discover request and job requests off another server that does have pear, but this is very ugly hack).

Any suggestions welcomed.

./tim

 
Avatar Bruno Celeste 374 posts

cURL is an alternative.

 
Avatar timh 4 posts

any sample code that can be shared? Here are my pear calls that I want to replace…

require_once “HTTP/Request.php”; // PEAR HTTP request

// upload file $rawfile = ‘http://www…..mov’;

$req =& new HTTP_Request(“http://heywatch.com/discover.xml”); $req->setBasicAuth(“XXXXXXXXX”, “XXXXX”); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addPostData(“url”, $rawfile); $req->addPostData(“title”, $filename); $req->addPostData(“download”, “true”); $req->addPostData(“automatic_encode”, “true”); $req->addPostData(“keep_video_size”, “false”); $req->addPostData(“my_video_id”, $my_video_id);

if (!PEAR::isError($req->sendRequest())) { $response = $req->getResponseBody();} // return XML; up to you to parse it or not print($response); } else { $response = “Request error”; }

error_log(‘Send to heywatch response: ’ . $response, 0);

and…

require_once “HTTP/Request.php”; $req =& new HTTP_Request($heywatchpath); $req->setBasicAuth(“XXXXX”, “XXXXXX”); $req->sendRequest(); $real_url = $req->getResponseHeader(“location”); $filename = substr($real_url, strrpos($real_url, ’/’) + 1);

//OK, we have the location of the file ($real_url), the filename ($filename), and the file ID ($my_video_id) //post all this back to download the file and update the media record…

$req =& new HTTP_Request(“http://mysite.com/download_encoded.php”); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addPostData(“url”, $real_url); $req->addPostData(“filename”, $filename); $req->addPostData(“my_video_id”, $my_video_id);

if (!PEAR::isError($req->sendRequest())) { $response = $req->getResponseBody();} // return XML; up to you to parse it or not print($response); } else { $response = “Request error”; }

error_log(‘Send to netcaster response: ’ . $response, 0);