Sunday, June 5, 2022
HomeWordPress Developmentphp - Why wp_remote_get() fetches sure net pages whereas it does not...

php – Why wp_remote_get() fetches sure net pages whereas it does not work for my localhost?


Why I am not capable of parse csv information (or equivalently open them) utilizing WordPress shortcode?

Downside: I want to use a shortcode to Parse Contents of a csv file and show its contents successfully. However the issue is that for some motive, the file does not opens/exhibits up regardless of completely different flip arounds. The server logs say that the GET request to the file was profitable.

My Shortcode:

operate wpb_demo_shortcode() { 
    if (($open = fopen("http://localhost:8000/a.csv", "r")) !== FALSE) 
  {
  
    whereas (($knowledge = fgetcsv($open, 1000, ",")) !== FALSE) 
    {        
      $array[] = $knowledge; 
    }
  
    fclose($open);
  }
  echo "<pre>";
  //To show array knowledge
  var_dump($array);
  echo "</pre>";
}
add_shortcode('website-url-name', 'wpb_demo_shortcode');

There are comparable questions round: Why is file_get_contents returning web page supply?

Once more the answer returns no completely different. It is displaying a clean pop up for me. I do not even know what’s the issue with WordPress as a result of common plain PHP script is ready to render it efficiently.

Kindly enlighten the error right here.

EDIT: I simply discovered that as a substitute of utilizing localhost:8000, I used https://pippinsplugins.com/edd-api/merchandise and it really works like a magic. I do not know why it isn’t capable of get information information from my localhost. Very bizarre.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments