diff --git a/_credentials_example/.gitkeep b/_credentials_example/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/_credentials_example/client_secret.json b/_credentials_example/client_secret.json new file mode 100644 index 00000000..bfda3599 --- /dev/null +++ b/_credentials_example/client_secret.json @@ -0,0 +1,2 @@ +{"installed":{"client_id":"XYZ.apps.googleusercontent.com","project_id":"yourproject_with_youtube_access","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"XYZXYZ"}} + diff --git a/_credentials_example/fedi_accounts.txt b/_credentials_example/fedi_accounts.txt new file mode 100644 index 00000000..d6f6fa63 --- /dev/null +++ b/_credentials_example/fedi_accounts.txt @@ -0,0 +1,2 @@ +your.instance.org|XXXYYY +another.instance.com.br|XXXYYY diff --git a/_credentials_example/fedilist_id.txt b/_credentials_example/fedilist_id.txt new file mode 100644 index 00000000..4859b3e9 --- /dev/null +++ b/_credentials_example/fedilist_id.txt @@ -0,0 +1 @@ +XXXXXXXYYYYYYYYY diff --git a/_credentials_example/readeck_account.txt b/_credentials_example/readeck_account.txt new file mode 100644 index 00000000..d0c57fe2 --- /dev/null +++ b/_credentials_example/readeck_account.txt @@ -0,0 +1 @@ +your.readeck.fr|XXXXXYYYY diff --git a/_credentials_example/token.json b/_credentials_example/token.json new file mode 100644 index 00000000..c2c648ed --- /dev/null +++ b/_credentials_example/token.json @@ -0,0 +1 @@ +{"access_token":"XXXYYY","expires_in":3599,"refresh_token":"1\/\/AAABBBCCC","scope":"https:\/\/www.googleapis.com\/auth\/youtube","token_type":"Bearer","expires_at":1755745256} diff --git a/fedi_slurp.php b/fedi_slurp.php index 04426e4d..1f8437e2 100755 --- a/fedi_slurp.php +++ b/fedi_slurp.php @@ -1,31 +1,63 @@ #!/usr/bin/php true, + CURLOPT_USERAGENT => "FediSlurperScript/1.0 (https://code.lema.org/santiago/fedi_slurp)", + CURLOPT_HTTPHEADER => [ "Authorization: Bearer $MASTODON_TOKEN", "Accept: application/json" @@ -40,6 +72,8 @@ if (!is_array($bookmarks)) { echo "Found bookmarks:".count($bookmarks)."\n"; +#print_r($bookmarks); + //----------------------------- // FIND VALID URLs in posts //----------------------------- @@ -62,12 +96,17 @@ foreach ($bookmarks as $status) { } } -if ($links) +if (isset($links)) +{ echo "Valid URLS:".count($links)."\n"; -else - echo "NO links founds \n"; print_r($links); +} +else +{ + echo "NO links founds. Kthxbye \n"; + die(0); +} //----------------------------- // SEND LINKS TO READECK @@ -92,7 +131,6 @@ if (!is_dir($alreadySentDir)) { mkdir($alreadySentDir, 0755, true); // recursive mkdir } -require("add_to_fedilist.php"); foreach ($links as $link) { @@ -177,3 +215,32 @@ if (isYouTubeLink($link)) { } curl_close($ch); + +} // end accounts loop + + +function loadAccounts(string $filepath): array { + $accounts = []; + + if (!file_exists($filepath)) { + return $accounts; // empty if file not found + } + + $lines = file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + + foreach ($lines as $line) { + $line = trim($line); + if ($line === '') continue; + + [$host, $token] = explode('|', $line, 2); + $accounts[] = [ + 'host' => $host, + 'token' => $token + ]; + } + + return $accounts; +} + + +