ASCIIBin follows the MVC architectural design pattern. As such, it uses a front controller so all actions are issued through index.php. This means all of your submissions should be to: ASCIIBin [Code and Text Collaboration for Debugging] - ASCIIBin[/URL]
Here are the [U]BIN Submission Variables [/U]available:
[*][B]a[/B] -> Action. Defaults to main page if blank. Use [B]add[/B] to submit a new bin
[*][B]p[/B] -> Private. Set to [B]on[/B] to make public. Default is off
[*][B]l[/B] -> Sets the bin to a Link. Set value to [B]on[/B] if submitting a link. Link must contain a valid URL and only a URL. No other text. [B]p [/B]will be set to off when this vairable is on.
[*][B]type [/B]-> This flag determines the output/confirmation of submitted text. Valid values are [U]text[/U], [U]xml[/U] or [U]html[/U]. HTML is default.
[*][B]tags[/B] -> Tags, seperated by commas
[*][B]pasteinfo[/B] -> The actual information you wish to paste. This is the textarea name. Cannot be blank
[*][B]emailself[/B] -> Send a reminder to yourself. you must be logged in for this function to work.
[*][B]emaildelay[/B] -> If emailself is on, use this variable to set the amount of time to delay before sending the email reminder. The value is in days and must be an INT.
[*][B]passOn[/B] -> Set this variable to [B]on[/B] if you would like to password protect your BIN submission.
[*][B]passtext[/B] -> The password to set if passOn is enabled
[*][B]subscribe [/B]-> Set to [B]on[/B] to subscribe to BIN comments. You will receive an email for each comment. User must be logged in.
[*][B]a[/B] -> Action. Set to "[I]login"[/I]
[*][B]sublogin[/B] -> Secondary process action. Set to [B]1[/B]
[*][B]user [/B]-> Username
[*][B]pass [/B]-> Password
[*][B]remember[/B] -> Set to [B]on[/B] if you would like your session to be remembered. This will set a cookie.
First, we do our basic cURL setup. I'll not go into detail about the functions of cURL. You can read about that here: [URL="http://www.php.net/curl"]PHP: cURL - Manual[/URL]
[php]$curl_connection = curl_init('http://www.asciibin.com/index.php');
curl_setopt($curl_connection, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($curl_connection, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
[/php]You can see above we set the URL to [URL="http://www.asciibin.com/index.php"]ASCIIBin [Code and Text Collaboration for Debugging] - ASCIIBin[/URL]. You must set a cookiejar and cookiefile in order to login. The rest you can read about yourself from the PHP Manual.
The following will show you how to login using cURL. If you wish to submit BINs anonymously, skip to the next section. To login we will use this query string:
[php]user=<username>&pass=<password>&sublogin=1&a=login[/php]Here is how:
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, "user=<username>&pass=<password>&sublogin=1&a=login");
[/php]This will submit a login request and actually write your session data to the cookie.txt file, set above. It will look like this:
[code]www.asciibin.com FALSE / FALSE 0 PHPSESSID 5e4223f348321e6328d58863b9870aa9[/code][B]
Now it is time to submit/create the BIN. To submit a bin, we need to send variables [B]a [/B]and [B]pasteinfo[/B]. You can include any of the variables from above as well. In this example I've included [B]a, p, tags[/B], [B]pasteinfo[/B] and [B]type[/B]. You might want to include type in yours as well in order to parse the response better.
* Submit Text now
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, "a=add&p=on&tags=codecall,tutorial&pasteinfo=This is a Tutorial&type=text");
$result = curl_exec($curl_connection);
[/php][I]$data[/I] is a variable set earlier which contains the submission text.
[I]pasteinfo[/I] can include BBCode. Code blocks should be wrapped with the code tag in this format: [noparse][code=language]// code[/code][/noparse]. ASCIIBin uses GeSHi so it supports all of the languages found here: GeSHi - Generic Syntax Highlighter :: Home (look along the left hand column).
$resultnow contains your data. Since I chose a 'text' return type, it will contain the URL of the newly submitted bin.
NOTE: If any of the text you submit contains an &, it will need to be URL encoded. You can do that in PHP using urlencode().
You need to close your cURL connection now:
If you are having problems connecting/submitting to ASCIIBin, you can print out the curl connection results:
print_r(curl_getinfo($curl_connection));This should give you an idea of the problem. If you need any help or assistance, please feel free to ask me.
Since this is a promo for ASCIIBin, I've pasted the full code for the submit function on ASCIIBin. You can tear through it however you like.
[URL="http://www.asciibin.com/QIL"]Full Source - ASCIIBin