[PHP] curl equivalent in PHP

2012-03-02 Thread Nibin V M
Hello,

I am trying to display the website content through a php code ( my own
websites; doesn't cause copy right issues ).

I use curl to display the page via the following simple code.

?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, http://mytest.com;);
curl_exec ($curl);
curl_close ($curl);
?

But on some of my servers, curl isn't enabled! Is there any equivalent code
to  achieve the same?

Thank you,

-- 
Regards

Nibin.

http://TechsWare.in


Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Nibin V M
Thanks Marc. But that need to add the DOM parser to the server. What I am
looking for something like iframe in html and that doesn't require any
additional PHP modules ( I do would like to avoid additions to the current
php; that is why I didn't compiled in curl )

On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote:

 http://simplehtmldom.sourceforge.net/

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards

Nibin.

http://TechsWare.in


Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Nibin V M
Thanks Marc. But that need to add the DOM parser to the server. What I am
looking for something like iframe in html and that doesn't require any
additional PHP modules ( I do would like to avoid additions to the current
php; that is why I didn't compiled in curl )

On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M nibi...@gmail.com wrote:

 Thanks Marc. But that need to add the DOM parser to the server. What I am
 looking for something like iframe in html and that doesn't require any
 additional PHP modules ( I do would like to avoid additions to the current
 php; that is why I didn't compiled in curl )


 On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote:

 http://simplehtmldom.sourceforge.net/

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




 --
 Regards

 Nibin.

 http://TechsWare.in




-- 
Regards

Nibin.

http://TechsWare.in


Re: [PHP] curl equivalent in PHP

2012-03-02 Thread FeIn
http://www.php.net/manual/en/function.stream-context-create.php

On Fri, Mar 2, 2012 at 4:44 PM, Nibin V M nibi...@gmail.com wrote:

 Thanks Marc. But that need to add the DOM parser to the server. What I am
 looking for something like iframe in html and that doesn't require any
 additional PHP modules ( I do would like to avoid additions to the current
 php; that is why I didn't compiled in curl )

 On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M nibi...@gmail.com wrote:

  Thanks Marc. But that need to add the DOM parser to the server. What I am
  looking for something like iframe in html and that doesn't require any
  additional PHP modules ( I do would like to avoid additions to the
 current
  php; that is why I didn't compiled in curl )
 
 
  On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote:
 
  http://simplehtmldom.sourceforge.net/
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  --
  Regards
 
  Nibin.
 
  http://TechsWare.in
 
 


 --
 Regards

 Nibin.

 http://TechsWare.in



Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Jim Lucas

On 03/02/2012 06:26 AM, Nibin V M wrote:

Hello,

I am trying to display the website content through a php code ( my own
websites; doesn't cause copy right issues ).

I use curl to display the page via the following simple code.

?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, http://mytest.com;);
curl_exec ($curl);
curl_close ($curl);
?

But on some of my servers, curl isn't enabled! Is there any equivalent code
to  achieve the same?

Thank you,



As long as you do not need to perform posts to the other website via the 
PHP request, you could include, file_get_contents, fopen + fread, etc...


All you need to make sure is that allow_url_fopen is enabled.

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Nibin V M
Thanks guys :)

Now another problem...I use a test domain ( say blahblah.com ) for testing
this, which isn't registered yet. So with the given code the index page is
loading fine. But when I try to click on any links, it will redirect to the
original domain which isn't exists!

( I have actually pointed the test domain to my server via hosts file on
the server )

So I wanted to browse the website via a PHP script, same as if I use a
browser on the server.

Hope you get me! :)

Is there any way to achieve this via PHP?

What I wanted to

On Fri, Mar 2, 2012 at 9:37 PM, Jim Lucas li...@cmsws.com wrote:

 On 03/02/2012 06:26 AM, Nibin V M wrote:

 Hello,

 I am trying to display the website content through a php code ( my own
 websites; doesn't cause copy right issues ).

 I use curl to display the page via the following simple code.

 ?php
 $curl = curl_init();
 curl_setopt ($curl, CURLOPT_URL, http://mytest.com;);
 curl_exec ($curl);
 curl_close ($curl);
 ?

 But on some of my servers, curl isn't enabled! Is there any equivalent
 code
 to  achieve the same?

 Thank you,


 As long as you do not need to perform posts to the other website via the
 PHP request, you could include, file_get_contents, fopen + fread, etc...

 All you need to make sure is that allow_url_fopen is enabled.

 --
 Jim Lucas

 http://www.cmsws.com/
 http://www.cmsws.com/examples/
 http://www.bendsource.com/




-- 
Regards

Nibin.

http://TechsWare.in


Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Micky Hulse
Hello,

On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas li...@cmsws.com wrote:
 But on some of my servers, curl isn't enabled! Is there any equivalent
 code
 to  achieve the same?

I've used a combination of output buffering [1], readfile() [2] and
caching (specific to the framework I was using).

Simply, you could resort to:

?php readfile('http://www.google.com'); ?

Ofc, the links would need to be absolute in order for the assets to load.

Good luck!

Cheers,
Micky

[1] php.net/ob-start
[2] php.net/readfile

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Daniel Brown
On Fri, Mar 2, 2012 at 11:29, Nibin V M nibi...@gmail.com wrote:
 Thanks guys :)

 Now another problem...I use a test domain ( say blahblah.com ) for testing
 this, which isn't registered yet. So with the given code the index page is
 loading fine. But when I try to click on any links, it will redirect to the
 original domain which isn't exists!

?php
echo 
str_replace('blahblah.com','localhost',file_get_contents('remote-domain.example.com'));
?

Modify it as needed, and if you want to surf the site using the
script as a proxy, add the logic to handle that.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Nibin V M
Hmm..I am a php newbie ( just started learning it )...

what my need is to display website from my server always for a
non-registered domain.This is the code I use now to display the website

?php
$opts = array(
  'http'=array(
'method'=GET,
'header'=Accept-language: en\r\n .
  Cookie: foo=bar\r\n
  )
);

$context = stream_context_create($opts);

$fp = fopen('http://www.blahblah.com', 'r', false, $context);
fpassthru($fp);
fclose($fp);
?

Of course blahblah.com isn't registered yet. This will load the index page
of blahblah.com fine ( since I use hosts file to resolve blahblah.com on
the server ). But if we click on any link, it will give server not found
error since my local machine is trying to resolve blahblah.com this time.
I need to avoid it and want to load my domain always from the server when
I click any link on the webpage, etc .

How can I modify the above code to make it work! If possible, I request
somebody to tell me the exact code that I need to change in the above
script - since most of the php part is still greek to me :)

Thank you,



On Fri, Mar 2, 2012 at 10:09 PM, Micky Hulse rgmi...@gmail.com wrote:

 Hello,

 On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas li...@cmsws.com wrote:
  But on some of my servers, curl isn't enabled! Is there any equivalent
  code
  to  achieve the same?

 I've used a combination of output buffering [1], readfile() [2] and
 caching (specific to the framework I was using).

 Simply, you could resort to:

 ?php readfile('http://www.google.com'); ?

 Ofc, the links would need to be absolute in order for the assets to load.

 Good luck!

 Cheers,
 Micky

[1] php.net/ob-start
[2] php.net/readfile

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards

Nibin.

http://TechsWare.in


Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Matijn Woudt
On Fri, Mar 2, 2012 at 6:09 PM, Nibin V M nibi...@gmail.com wrote:
 Hmm..I am a php newbie ( just started learning it )...

 what my need is to display website from my server always for a
 non-registered domain.This is the code I use now to display the website

 ?php
 $opts = array(
  'http'=array(
    'method'=GET,
    'header'=Accept-language: en\r\n .
              Cookie: foo=bar\r\n
  )
 );

 $context = stream_context_create($opts);

 $fp = fopen('http://www.blahblah.com', 'r', false, $context);
 fpassthru($fp);
 fclose($fp);
 ?

 Of course blahblah.com isn't registered yet. This will load the index page
 of blahblah.com fine ( since I use hosts file to resolve blahblah.com on
 the server ). But if we click on any link, it will give server not found
 error since my local machine is trying to resolve blahblah.com this time.
 I need to avoid it and want to load my domain always from the server when
 I click any link on the webpage, etc .

 How can I modify the above code to make it work! If possible, I request
 somebody to tell me the exact code that I need to change in the above
 script - since most of the php part is still greek to me :)

 Thank you,

Have you actually read/tried Daniel Browns reply?

The following seems to be all you need...

?php
echo str_replace('blahblah.com','localhost',file_get_contents('blahblah.com'));
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php