0

I recently began programming in PHP, and started new personal project of mine, a PHP-based news website that generates top headlines around specific topics. I am using PHP 7.4.4, Bootstrap, and a little bit of CSS. Everything's been going pretty well, any errors solved, any questions answered by search. At least until I started actually inserting the actual news into my website. When I tried to use my api key(API Key from https://newsapi.org) to insert the live news into my "Sports News" page, an error showed up on the top of the page:

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading in /opt/lampp/htdocs/news/app/views/news/sportNews.php on line 18

The news does show up on my screen, but the error still does not budge, even after repeated attempts to fix the bug.

Here is my sportNews.php:

<?php $this->setSiteTitle('News'); ?> <?php $this->start('body'); ?> <head> <link href="css/newscss.css" rel="stylesheet"></link> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> </head> <body> <?php //API_KEY filled in when running program $url = "https://newsapi.org/v2/everything?q=sports&apiKey=API_KEY"; $response = file_get_contents($url); //ERROR LINE $NewsData = json_decode($response); ?> <div class="jumbotron"> <h1>Sports News</h1> </div> <div class="container-fluid"> <?php foreach($NewsData->articles as $News) { ?> <div class="row"> <div class="col-md-3"> <img src="<?php echo $News->urlToImage ?>" alt="News thumbnail"> </div> <div class="col-md-9"> <h2>Title: <?php echo $News->title ?></h2> <h5>Description: <?php echo $News->description ?></h5> <p>Preview/Content: <?php echo $News->content ?></p> <h6>Author: <?php echo $News->author ?></h6> <h6>Published <?php echo $News->publishedAt ?></h6> </div> <?php } ?> </div> </div> </body> <?php $this->end(); ?> 

I have tried multiple times to fix this bug, including testing answers from similar stack overflow questions, all to no result. After a thorough search, and I still no results, I decided to ask a question. Any help appreciated

1 Answer 1

1

This happens when your client can't establish a version. That error happens when you have an older PHP-Version and a newer openssl version. In newer version you have some braking changes and you get that error.

https://github.com/dask/gcsfs/issues/246

what you can try is to downgrade or upgrade your openssl version. That bug should appear in version 1.1.1e. So check your openssl version first and that take a look if you can upgrade it.

OpenSSL.SSL.Error: [('SSL routines', 'ssl3_read_n', 'unexpected eof while reading')] when updating / searching / installing conda packages

Here is another helpfull post for yum.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.