Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* An open-source example of using the Pastebin API in PHP and HTML5.
- This is used to create and store a UserID.
- This will be connected to other PHP files, listed below when they are posted:
- Pastebin.php: https://pastebin.com/wyz1MD8B
- removeCookie.php: https://pastebin.com/yTES7RYs
- Testing.php: https://pastebin.com/iZUEDFfX
- */
- $theuser = $_POST["user"];
- $thepass = $_POST["pass"];
- $api_dev_key = '';
- $api_user_name = urlencode($theuser);
- $api_user_password = urlencode($thepass);
- $url = 'https://pastebin.com/api/api_login.php';
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_dev_key='.$api_dev_key.'&api_user_name='.$api_user_name.'&api_user_password='.$api_user_password.'');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 0);
- $response = curl_exec($ch);
- if (strpos($response, 'Bad API request') !== false) {
- echo "<p>An error occured.</p><p>$response</p>\n";
- echo "<p>Use the link below to go back to the Pastebin API.</p>\n";
- } elseif (strpos($response, 'CAPTCHA') !== false) {
- echo "<p style='color:red'>The pastebin API has refused the request, due to CAPTCHA test.</p>";
- } else {
- echo "<p>Success!</p>\n";
- setcookie("userid", $response, time() + "3600", "/");
- echo "<p>Use the link below to go back to the Pastebin API.</p>\n";
- }
- ?>
- <!DOCTYPE html>
- <html>
- <body><br>
- <a href="/Pastebin.php">Back to Pastebin.php</a>
- </body>
- </html>
Add Comment
Please, Sign In to add comment