sandip1110
Active Member
This code is working but now paste2.org has made some changes..
earlier paste2 like, http://paste2.org/p/UNIQUEID
now its like, http://paste2.org/UNIQUEID
so can any one edit below code and make it working.
Regards.
earlier paste2 like, http://paste2.org/p/UNIQUEID
now its like, http://paste2.org/UNIQUEID
so can any one edit below code and make it working.
Regards.
Code:
function createPaste2($desc, $code)
{
$desc = urlencode($desc);
$code = urlencode($code);
$ch = curl_init('http://paste2.org/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "code=$code&lang=text&description=$desc&parent=0");
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
$page = curl_exec($ch);
curl_close($ch);
preg_match('#Location: /p/(\d+)#', $page, $match);
return 'http://paste2.org/' . $match[1];
}