Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Wordpress' http.php in external projects?
    primarykey
    data
    text
    <p>Answer : Implemented using Curl...</p> <pre><code>$file = "http://abc.com/data//output.txt"; $ch = curl_init($file); $fp = @fopen("out.txt", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $file = "out.txt"; $fp = fopen($file, "r"); </code></pre> <p>I am trying to parse data from a pipe-delimited text file hosted on another server which in turn will be inserted in a database. My host (1and1) disabled <strong>allow_url_fopen</strong> in <strong>php.ini</strong> I guess.</p> <p>Error message :</p> <pre><code>Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in </code></pre> <p>Code :</p> <pre><code> &lt;? // make sure curl is installed if (function_exists('curl_init')) { // initialize a new curl resource $ch = curl_init(); // set the url to fetch curl_setopt($ch, CURLOPT_URL, 'http://abc.com/data/output.txt'); // don't give me the headers just the content curl_setopt($ch, CURLOPT_HEADER, 0); // return the value instead of printing the response to browser curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // use a user agent to mimic a browser curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0'); $content = curl_exec($ch); // remember to always close the session and free all resources curl_close($ch); } else { // curl library is not installed so we better use something else } //$contents = fread ($fd,filesize ($filename)); //fclose ($fd); $delimiter = "|"; $splitcontents = explode($delimiter, $contents); $counter = ""; ?&gt; &lt;font color="blue" face="arial" size="4"&gt;Complete File Contents&lt;/font&gt; &lt;hr&gt; &lt;? echo $contents; ?&gt; &lt;br&gt;&lt;br&gt; &lt;font color="blue" face="arial" size="4"&gt;Split File Contents&lt;/font&gt; &lt;hr&gt; &lt;? foreach ( $splitcontents as $color ) { $counter = $counter+1; echo "&lt;b&gt;Split $counter: &lt;/b&gt; $colorn&lt;br&gt;"; } ?&gt; </code></pre> <p>Wordpress has this cool http.php file. Is there a better way of doing it? If not, how do I use http.php for this task? Thank you guys..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload