Advertisement
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 post a new paste.
- its called testing.php cause it was originally a test and i was too lazy to change the name
- 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
- formUserId.php: https://pastebin.com/Y0ZAtddd
- */
- if(!isset($_COOKIE["userid"])) {
- $GLOBALS["api_user_key"] = "";
- } else {
- if ($_POST["anon"] == "yes") {
- $GLOBALS["api_user_key"] = "";
- } else {
- $GLOBALS["api_user_key"] = $_COOKIE["userid"];
- }
- }
- $api_dev_key = ""; // your api_developer_key
- $api_paste_code = $_POST["paste"]; // your paste text
- $api_paste_private = $_POST["exposure"]; // 0=public 1=unlisted 2=private
- $api_paste_name = $_POST["name"]; // name or title of your paste
- $api_paste_expire_date = $_POST["expire"];
- $api_paste_format = $_POST["file"];
- $api_paste_name = urlencode($api_paste_name);
- $api_paste_code = urlencode($api_paste_code);
- $url = "https://pastebin.com/api/api_post.php";
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "api_option=paste&api_user_key=".$api_user_key."&api_paste_private=".$api_paste_private."&api_paste_name=".$api_paste_name."&api_paste_expire_date=".$api_paste_expire_date."&api_paste_format=".$api_paste_format."&api_dev_key=".$api_dev_key."&api_paste_code=".$api_paste_code."");
- 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";
- echo "<p><a href='$response' target='_blank'>$response</a></p>\n";
- }
- $content = substr($response,21);
- echo "<iframe src='https://pastebin.com/embed_iframe/$content' style='border:none;width:100%'></iframe>";
- ?>
- <!DOCTYPE html>
- <html>
- <body>
- <a href="/Pastebin.php">Back to Pastebin.php</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement