File Context with PHP 4.4.7

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi, I'm trying to perform an XMLRPC request as seen in the PHP site,
the only problem is, as the PHP version in my server is 4.4.7(i.e. <
5.0), there is no support to contexts, and the page keeps sending me
warnings about file_get_contents only accepting 2 arguments.

So, what's the alternative to perform a pingback?

The code is as follows:

$request = xmlrpc_encode_request("", array(HTTP_ROOT."/?
post=".$post_id,$uri), array("encoding" => "utf-8"));

$http_info = array(

    'method' => "POST",

    'header' => "Content-Type: text/xml; charset=utf-8",

    'content' => $request,


$context = stream_context_create(array('http' => $http_info));

$file = file_get_contents($pingback, false, $context);

As you see, the method of data sending must be post(the target script
for pingbacking uses POST variables), so a context NULL just don't get
any response from the server.

Anyway, how to use context in PHP < 5.0?

Re: File Context with PHP 4.4.7

bruno_guedesav wrote:
Quoted text here. Click to load it

The short answer is, you can't.

The longer answer is, your code isn't safe, anyway.  The Xmlrpc
extension is still listed as experimental in PHP 5.2.1 and likely to
remain that way for a while.  The function is not officially supported
and can change at any time.

My suggestion would be for you to upgrade to PHP 5.x - or, if you're on
a shared host and they won't upgrade, find another host.

Alternatively, you should be able to emulate the xmlrpc functions with
cURL, but I haven't tried it.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline