Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // send_data_to_pastebin ([ 'api_key'=>$GLOBALS['pastebin_api_key'], 'user_key'=>$GLOBALS['pastebin_user_key'], 'public'=>'1', 'expiration'=>'1M', 'content'=>$content, 'title'=>'untitled' ])
- public function create_pastebin( $content, $array= array())
- {
- // https://pastebin_com/api#1
- $api_dev_key = $array['api_key'];
- $api_paste_code = $content;
- $api_paste_private = $array['public'];
- $api_paste_name = $array['title'];
- $api_paste_expire_date = $array['expiration'];
- $api_paste_format = 'text';
- $api_user_key = $array['user_key']; // if an invalid or expired api_user_key is used, an error will spawn. If no api_user_key is used, a guest paste will be created
- $url = str_replace('com','.com','https://pastebincom/api/api_post.php'); //funny, but pastebin links are detected as malware on hostings (they think fight malware by detecting "pastebing" phrase :)) (replacement url: https://goo.gl/bRV6dE )
- $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='.urlencode($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='.urlencode($api_paste_code).'');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 9);
- curl_setopt($ch, CURLOPT_REFERER, $url);
- curl_setopt($ch, CURLOPT_TIMEOUT, 60);
- curl_setopt($ch, CURLOPT_AUTOREFERER, true);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 0);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 0);
- $response = curl_exec($ch);
- return $response;
- }
- // github api for GIST create
- public function create_gist($content, $token=""){
- $url = 'https://api.github.com/gists';
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_POST, 1);
- $header[]= "User-Agent: My App Name,Website or Email (for identification)";
- $header[]= "Authorization: token $token"; //basic base64_encode("username:password");
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- $data = array(
- "description"=> "descr",
- "public"=> true,
- "files" => array(
- "file1.txt"=> array(
- "content" => $content
- )
- )
- );
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data) );
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($ch);
- curl_close($ch);
- return $response;
- // $response ['html_url'] -----> https://gist.github.com/0f62b7edeb2f03af1ec8d10558b7d67a
- // ['raw_url'] -----> https://gist.github usercontent.com/anonymous/0f62b7edebd1057d67a/raw/b004869d73c82d0d1/file1.txt
- // ['url'] -----> .... just contains some info about the api call
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement