Connecting Tech Pros Worldwide Forums | Help | Site Map

File Context with PHP 4.4.7

bruno_guedesav
Guest
 
Posts: n/a
#1: Mar 10 '08
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("pingback.ping", 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?

bruno_guedesav
Guest
 
Posts: n/a
#2: Mar 18 '08

re: File Context with PHP 4.4.7


Bumping. This one seems hard, eh?
Jerry Stuckle
Guest
 
Posts: n/a
#3: Mar 18 '08

re: File Context with PHP 4.4.7


bruno_guedesav wrote:
Quote:
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("pingback.ping", 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?
>
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.
jstucklex@attglobal.net
==================

bruno_guedesav
Guest
 
Posts: n/a
#4: Mar 18 '08

re: File Context with PHP 4.4.7


Quote:
>
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.
jstuck...@attglobal.net
==================
Oh, cool...

Unfortunately, the host is already paid so... no, it won't do.

Any hints on where to start trying to make a pingback response with
cURL?
Jerry Stuckle
Guest
 
Posts: n/a
#5: Mar 18 '08

re: File Context with PHP 4.4.7


bruno_guedesav wrote:
Quote:
Quote:
>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.
>jstuck...@attglobal.net
>==================
>
Oh, cool...
>
Unfortunately, the host is already paid so... no, it won't do.
>
Any hints on where to start trying to make a pingback response with
cURL?
>
Start with the cURL doc. It's not too hard once you get used to it -
the biggest part might be building the stream and interpreting the response.

And just because a host is paid for doesn't mean you shouldn't change.
How much have you paid - vs. how much are you going to waste in time
trying to get something else to work? Sometimes it's better to cut your
losses if they won't upgrade.

Also a good reason not to pay too far in advance.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Closed Thread