This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
iAd4m's profile picture

HTTP Email Client

Started by iAd4m, 19 April 2015 - 01:00 AM
iAd4m #1
Posted 19 April 2015 - 03:00 AM
Nameless Email API




I made this as I thought it would be cool to send emails across a server and I did it as something to do and it was a good learning experience. So here it is you can make your own client if you'd like the API-thingy will be below and should be relatively easy to understand. I will be releasing my own email client soon that you can use as a user rather then a developer so check back within a few days of this topic being posted.

Return Codes
Spoiler101 = Unknown username
102 = Wrong password
103 = Username already taken
104 = Registered Successfully
105 = No emails
106 = No message to send
107 = Missing data in sent message
108 = Message Sent
109 = Unknown Protocol
110 = Authenticated

There are two functions that you will need to use, loadJSON, which will check if you already have the json api installed if not it will download it from pastebin and put it in, ".emails/json". It also checks to make sure you have http enabled and if not it will tell you that you need to enable the http api. The other function is retrieve, it has 3 required parameters, username, password, and protocol, and a optional parameter sendData, sendData is used only for sending messages and I will go over how to do that in a second. The first two paramaters, username and password are super simple to understand, the password is encrypted on the PHP side of things with sha512 so you wont have to have any extra API's. The protocol parameter is easy aswell, there are three options you can put in there. Register, Fetch, and Send. If you enter an invalid protocol it will return with the return code 109. The optional sendData is only used when sending a message and it must be a table with the four following variables, to, the person the message is going to, from, the sender, subject, the subject of the message, and data, the long bunch of text that is usually in an email. Oops! Almost forgot, when you fetch emails they return as tables so for each email it will return as a table. Also there is another protocol, 'authenticated' will return 110. That should be it, if I have left anything out please let me know in the comments and I will fix it.

Pastebin:

http://pastebin.com/sgYCDbnP
pastebin get sgYCDbnP email
Edited on 02 May 2015 - 05:28 PM
Joelahughes #2
Posted 22 April 2015 - 04:12 PM
Cool! I think I am going to make a client for it! :)/>
Creator #3
Posted 22 April 2015 - 04:19 PM
Nameless.
iAd4m #4
Posted 25 April 2015 - 01:47 AM
Cool! I think I am going to make a client for it! :)/>

Sweet, upload it here and ill add it to the topic
Im working with a friend on one aswell so that will be released soon. If you find any bugs let me know.
Edited on 24 April 2015 - 11:48 PM
the_blaster179 #5
Posted 29 April 2015 - 04:56 AM
patebin

You made a typo in the installation code.
iAd4m #6
Posted 02 May 2015 - 07:28 PM
patebin

You made a typo in the installation code.
Thanks Ill fix that now