1. Go to this page and download the library: Download davor/news-recommendation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* This example shows how to ask OpenAI to create prompt for creating OpenAI image
*/
//using facade we create client and specify uri for OpenAI API
$askClient = \OpenAI::client('chat/completions');
//we ask for prompt (note that we use ['content'] to retrieve prompt)
$imagePrompt = $askClient->ask('Write best prompt for creating poster of Novak Djokovic being the best tennis player ever')['content'];
//using facade we create ampther client for image
$imageClient = \OpenAI::client('images/generations',60,'dall-e-3');
//we retrieve image url (by default)
$imageUrl = $imageClient->generateImage($imagePrompt)[0];
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Carbon;
public function readerData(){
$redisKeys = Redis::keys('*');
$data = request()->validate([
'article_id' => ['t are not older than 10 days
if($publishDate > now()->subDays(10)){
//extract reader string from redis and update it
$readerData = Redis::get('reader-'.$data['readerID']);
if($readerData){
Redis::append('reader-'.$data['readerID'],'|'.$data['article_id']);
}else{
Redis::set('reader-'.$data['readerID'],$data['article_id']);
}
}
}
<script>
function generateUUID() {
// Get current time in milliseconds
var d = new Date().getTime();
// Define the UUID template with placeholder characters
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
// Replace the placeholders with random hexadecimal digits
uuid = uuid.replace(/[xy]/g, function(c) {
// Generate a random number between 0 and 15
var r = (d + Math.random()*16)%16 | 0;
// Update value of d for the next placeholder
d = Math.floor(d/16);
// Convert the number to a hexadecimal digit and return it
return (c=="x" ? r : (r&0x3|0x8)).toString(16);
});
return uuid+'-'+{{$article['id']}};
}
$(document).ready(function() {
const reader = localStorage.getItem("reader");
var readerID;
// if there is reader take data
if(reader){
readerID = reader;
}else{
//generate readerID
readerID = generateUUID();
localStorage.setItem("reader",readerID);
}
console.log(readerID);
$.ajax({
type: "POST",
url: "{{route('frontend.ajax.reader')}}",
data: {
_token: "{{ csrf_token() }}",
article_id: {{$article['id']}},
readerID : readerID,
publish_at : "{{$article['publish_at']}}"
}
});
});
</script>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.