php larvel ytmp3
root@server:/home/backend.ytmp3.su/public_html# php artisan migrate --seed
- Application In Production! *
Do you really wish to run this command? (yes/no) [no]:
yes
Nothing to migrate.
Seeding: Database\Seeders\AdminSeeder
In helpers.php line 284:
** **The given data was invalid.****
php artisan migrate:fresh
getting error when pasting yt urls
No results
No results found
please enable Laravel Debug mode in .env file.
in /b.ytmp3.su/storage/logs
[2022-08-13 14:03:01] production.ERROR: array_merge(): Expected parameter 1 to be an array, null given {"exception":"[object] (ErrorException(code: 0): array_merge(): Expected parameter 1 to be an array, null given at /home/ytmp3/public_html/b.ytmp3.su/lib/Extractors/Youtube.php:0)
[stacktrace]
#0 /home/ytmp3/public_html/b.ytmp3.su/lib/Extractors/Youtube.php(0): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'array_merge(): ...', '/home/ytmp3/pub...', 0, Array)
#1 /home/ytmp3/public_html/b.ytmp3.su/lib/Extractors/Youtube.php(0): RajWebConsulting\\Extractors\\Youtube->ParseDownloadLinks('NEEuutK4moI')
#2 /home/ytmp3/public_html/b.ytmp3.su/app/Http/Controllers/ApiController.php(150): RajWebConsulting\\Extractors\\Youtube->GetDownloadLinks('https://www.you...')
#3 /home/ytmp3/public_html/b.ytmp3.su/app/Http/Controllers/ApiController.php(51): App\\Http\\Controllers\\ApiController->ValidRequest('RajWebConsultin...', 'https://www.you...')
please enable Laravel Debug mode in .env file.
Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all
- Login to your Cpanel
- Under Software click on MultiPHP INI Editor demo
- Click on Editor Mode and select Domain demo
- Paste allow_url_fopen = 1 and save
Go to:/usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini
And remove shell_exec from the disabled_functions
Adjust 7.4 with the version you are editing.
how to bring this function \GuzzleHttp\Client()
$client = new \GuzzleHttp\Client();
you have used this in your PHP API because the backend is on another server or
domain
see this https://docs.guzzlephp.org/en/stable/overview.html#installation
and https://github.com/guzzle/guzzle
also
am getting Errror You are not Authorized. Please check your allowed IPs.
Allow the Server IP where u use ur custom script. in Admin Panel IPv4 and IPv6 are possible.
or force ipv4 in ur curl code.
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);Installation
First, we start with the Guzzle installation. The recommended way to install the Guzzle library is through the Composer. Open the terminal in your project root directory and run the command.
composer require guzzlehttp/guzzle
Upon installing the library, we are ready to send HTTP requests. As mentioned, we will cover a major HTTP Request normally required for any application. Once you are familiar with it, you can explore other request options of your own provided by Guzzle.
How to Send HTTP Request using Guzzle
To get started, you need to include a Guzzle environment in your application as follows.
1 2 3 4 | <?phprequire_once "vendor/autoload.php"; use GuzzleHttp\Client; |
Now let’s write a code for our request options one by one.
GET Request using Guzzle
If you look at the REQ|RES service, they provided different endpoints for each HTTP request.
For the GET request, I will take an example of the ‘LIST USERS’ endpoint. To get the fake users list, it needs to send a GET request to this endpoint https://reqres.in/api/users?page=2.
In Guzzle, we send the above GET HTTP request as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?phprequire_once "vendor/autoload.php"; use GuzzleHttp\Client; $client = new Client([ // Base URI is used with relative requests]); $response = $client->request('GET', '/api/users', [ 'query' => [ 'page' => '2', ]]); $body = $response->getBody();$arr_body = json_decode($body);print_r($arr_body); |
term not searching for other words
all search for 'sia' only
stop using OPTIONAL parameter "nextPageToken" on the first request. and dont use the example "nextPageToken".
$jsonData = json_encode(['term' => 'YOUR_SONG']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);suddenly getting this error
[2022-08-17 15:30:49] production.ERROR: Undefined index: percentage_download {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined index: percentage_download at /home/ytmp3.su/public_html/app/Http/Livewire/DownloadModal.php:86)
Download.php
<?php
namespace RajWebConsulting;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
class Downloader
{
const _REQUEST_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36';
// Private Fields
private static $_curlResource;
private static $_percentVidDownloaded = 0;
private static $_fsize;
private static $_downloaded;
private static $_chunkCount = 0;
private static $_prevChunkCount = 0;
private static $_isChunkedDload;
private static $_progressCache;
public static function ChunkedDownload($remoteURL, $path, $sourceName, $fsize, $progressCache)
{
self::$_progressCache = $progressCache;
$storagePath = Storage::disk('public')->path($path);
if (!file_exists($storagePath))
{
mkdir($storagePath, 0777, true);
}
// die($storagePath);
self::$_isChunkedDload = true;
self::$_downloaded = self::$_percentVidDownloaded = 0;
self::$_fsize = $fsize;
$chunkEnd = $chunkSize = 1000000; // 1 MB in bytes
$numTries = $count = $chunkStart = 0;
$file = fopen($storagePath . $sourceName, 'a');
self::$_curlResource = $ch = curl_init();
while (self::$_fsize >= $chunkStart)
{
//curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $remoteURL);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array('self', self::ProgressFuncName()));
curl_setopt($ch, CURLOPT_BUFFERSIZE, $chunkSize);
curl_setopt($ch, CURLOPT_RANGE, $chunkStart . '-' . $chunkEnd);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, self::_REQUEST_USER_AGENT);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
$curlInfo = curl_getinfo($ch);
if ((curl_errno($ch) != 0 || $curlInfo['http_code'] != "206") && $numTries < 10)
{
$numTries++;
continue;
}
$numTries = 0;
fwrite($file, $output);
$chunkStart += $chunkSize;
$chunkStart += ($count == 0) ? 1 : 0;
$chunkEnd += $chunkSize;
self::$_chunkCount = ++$count;
}
curl_close($ch);
fclose($file);
self::$_prevChunkCount = self::$_chunkCount = 0;
}
public static function Download($remoteURL, $path, $sourceName, $progressCache)
{
self::$_progressCache = $progressCache;
$storagePath = Storage::disk('public')->path($path);
if (!file_exists($storagePath))
{
mkdir($storagePath, 0777, true);
}
self::$_isChunkedDload = false;
self::$_curlResource = $ch = curl_init();
self::$_percentVidDownloaded = 0;
$file = fopen($storagePath . $sourceName, 'w');
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $remoteURL);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array('self', self::ProgressFuncName()));
curl_setopt($ch, CURLOPT_BUFFERSIZE, 4096000);
curl_setopt($ch, CURLOPT_USERAGENT, self::_REQUEST_USER_AGENT);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
fclose($file);
curl_close($ch);
}
private static function ProgressFuncName()
{
return (self::$_isChunkedDload) ? 'UpdateVideoChunkDownloadProgress' : 'UpdateVideoDownloadProgress';
}
private static function UpdateVideoDownloadProgress($curlResource, $downloadSize, $downloaded, $uploadSize, $uploaded)
{
$httpCode = curl_getinfo($curlResource, CURLINFO_HTTP_CODE);
if ($httpCode == "200" && $downloadSize > 0)
{
$percent = round($downloaded / $downloadSize, 2) * 100;
if ($percent > self::$_percentVidDownloaded)
{
self::$_percentVidDownloaded++;
self::OutputDownloadProgress($percent, true);
}
}
}
private static function UpdateVideoChunkDownloadProgress($curlResource, $downloadSize, $downloaded, $uploadSize, $uploaded)
{
$httpCode = curl_getinfo($curlResource, CURLINFO_HTTP_CODE);
if ($httpCode == "206" && $downloadSize > 0 && self::$_chunkCount != self::$_prevChunkCount)
{
self::$_prevChunkCount++;
self::$_downloaded += $downloadSize;
$percent = round(self::$_downloaded / self::$_fsize, 2) * 100;
if ($percent > self::$_percentVidDownloaded)
{
self::$_percentVidDownloaded++;
self::OutputDownloadProgress($percent, true);
}
}
}
public static function OutputDownloadProgress($percent, $isRealTime)
{
$cDriver = env('CACHE_DRIVER', 'file');
Cache::store($cDriver)->put(self::$_progressCache, [
'percentage_convert' => 0,
'percentage_download' => $percent,
'status' => 'Downloading source file...'
], 2400);
// echo $percent;
if (ob_get_length() > 0) ob_end_flush();
if (ob_get_length() > 0) ob_flush();
flush();
}
}
when trying to enable API getting error
[2022-08-18 03:13:19] production.ERROR: Undefined index: singleDocs {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined index: singleDocs at /home/ytmp3.su/public_html/app/Http/Livewire/Admin/Settings/SettingsApiDocs.php:24
pls navigate to app/Http/Livewire/Admin/Settings/SettingsApiDocs.php und uncomment Line 15
public function mount()
{
$this->state = [
'singleDocs' => app(ApiDocSettings::class)->single,
'buttonDocs' => app(ApiDocSettings::class)->button,
'widgetDocs' => app(ApiDocSettings::class)->widget,
'jsonDocs' => app(ApiDocSettings::class)->json,
];
}Larvel file permission
cd [..LARAVEL PROJECT ROOT]
sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;
sudo chmod -R 777 ./storage
sudo chmod -R 777 ./bootstrap/cache/
Only if you use npm (VUE, compiling SASS, etc..) add this:
sudo chmod -R 777 ./node_modules/blank response from API URL even on terminal
turn off cloudflare CDN and also check curl it should not redirect from HTTP to https
[root@vmi780211 public]# curl -I http://backend.ytmp3.su/api/search
HTTP/1.1 301 Moved Permanently
[root@vmi780211 public]# curl --request POST \
> "http://b.ytmp3.su/api/search" \
> --header "apiKey: d9b6dcecb8ddce3c7b6b3cb92064874a7022fe3e" \
> --header "Content-Type: application/json" \
> --header "Accept: application/json" \
> --data "{
> \"term\": \"love song\",
>
> }"
{"error":true,"code":401,"errorMsg":"Unauthorized","message":"You are not Authorized. Please check your allowed IPs."}[root@vmi780211 public]#
How To install YouTube Video Backend on aaPanel (recommended)
sudo -u www unzip VideoBackendAPI-v3.*.*.zip && mv videobackendapi/* videobackendapi/.??* . && rm -rf videobackendapi VideoBackendAPI-v3.*.*.zip
7) Install dependencies via Composer
sudo -u www composer install --no-dev
8) Generate .env Config file
sudo -u www cp .env.example .env
9) Generate unique APP Key
php artisan key:generate
[root@server backend.ytmp3.su]# cat .env
APP_NAME="YouTube Video Backend"
APP_URL=http://backend.example.com
# Your MySQL Database Login details here
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ytmp3_backend
DB_USERNAME=ytmp3_backend
DB_PASSWORD=ppfK),nq_RoC
# If you want to use redis, set up your redis settings here.
#REDIS_HOST=127.0.0.1
#REDIS_PASSWORD=null
#REDIS_PORT=6379
# Cache Search and Video Extraction results for faster response.
CACHE_SEARCH_RESULTS=true
# Cache purges old results automatically after 3600 seconds (1 hour)
CACHE_SEARCH_EXPIRES=3600
# Cache Driver can be "file" or "redis"
CACHE_DRIVER=file
# Session Driver can be "file", "database", or "redis"
SESSION_DRIVER=file
SESSION_LIFETIME=120
# Changing values below is not recommended.
APP_ENV=production
APP_KEY=base64:bvjlQ0WVz9jfFrU5yRrSAB1rIAIIrR5my4wTCm27ag4=
APP_DEBUG=false
# Set the type of Errors logged in "storage/logs/laravel.log"
# The following values are accepted, ordered from least severe to most severe:
# "debug", "info", "notice", "warning", "error", "critical", "alert", or "emergency"
LOG_LEVEL=error
11) Migrate and Seed Database via SSH terminal
Nothing to migrate.
Seeding: Database\Seeders\AdminSeeder
In helpers.php line 284:
** **The given data was invalid.****
php artisan migrate:fresh
php artisan migrate --seed
13) Navigate to the Admin Panel, and Update your Email and Password
http://backend.example.com/admin
Login: admin@admin
Password: 12345678
waiting for free worker
Comments
Post a Comment