Short Version:
Anybody mind writing a fully functional script example for me that just creates a lesson with static values that creates a title, the main text and audio (i have some audio on my web server so if possible remote audio through url but if not i can download them locally). I’m having problems using the API documentation to figure out how to get started. I can do the my side computing of parsing data to send, but i’m having issues figuring out how to actually then take that and send it to lingq. Thank you so much :).
The Long of it:
I have like 300 audio lessons with transcripts and such like that that I would love to bring into lingq and study that way rather than as a bunch of files on my computer. I dont plan on bringing them all in at once, but I would like to create a little script that can do them in 50 lessons chunks as I need them.
I’ve done basic programming. I know how to take the data I have and parse it into elements that can hopefully be sent to lingq thorugh the API to make lessons out of all the information I have (currently i’ve already made a script that parses my system file and created an xml that holds all the audio locations for upload as well as parsing the text files for the transcripts and all that info is in an xml file ready to be parased again and hopefully uploaded. If it works that way.
But because my programming is new and limited, i’m having problems understanding the API documentation. I dont even know where to start. I was hoping somebody could create a little, fully functional script for me, preferably in PHP if possible, but I can figure out how javascript if need be, that would create a lessong. Using static variables is fine, I can create the dynamically updating loops for the information on my own, I think. I’m just really lost on how to connect to the lingq servers and start passing it the elements. Thank you so much! I hope this makes sense. I"m really new to all this.
this is what i’ve tried so far to no success
This is basically what I tried to do, with no results. I GET all my lessons in JASON (i think) but it wont allow me to create a lesson or course. Even a basic one like this.
Hi Norefund17, you are talking about “code”, “programming” and “script” …., but if you want to upload lessons in LINGQ, you don’t need these things! It is very simple: You begin with clicking on the plus symbol in the right upper corner of your screen. And then you get a kind of form in which you can fill in the name of your lesson, the lesson itself, the audio etc. If you have a lot of lessons that belong together you can put them together by creating a course. You had better creating the course when you import the first lesson. When creating the lesson, have a look on the possibilities of the button “resources”, which you find next to the button “title and text”.
thank you benscheelings, I appreciate your response. My main thing is that I want to write a code to loop through a bunch of lessons I have. Hundreds of them so I dont have to enter each by hand. Both for ease of importing them and also just as a little challenge because I enjoy programming and learning new aspects of it. Ive never delt with a REST api so i’m confused on how to just connect to the lingq db thorugh it so thats mainly what i’m trying to learn here. The rest of it, the sorting and cataloging the lessons through a code on my end, I should be able to handle. But when the REST api says "POST api/v2/lessons ", i’m not 100% sure what that means and i’m looking for a little guidance on how to get basic info sent through so I can expand from there. But i appreciate your response very much. Thank you :).
This is basically what I tried to do, with no results. I GET all my lessons in JASON (i think) but it wont allow me to create a lesson or course. Even a basic one like this.
the problem here is that you are sending a x-www-form-urlencoded payload as the body of the request, where (I assume) the API expects applicatoin/json or at least a JSON payload. If you really want to send JSON from a HTML form you need to first catch all those field values, build a JSON object, send the request (with AJAX) and then be able to read the JSON (I assume) response.
Here is a good tutorial on how to achieve that with HTML forms
I would build a command-line tool that parses the local lessons and then uses an http client to send the requests so I can concentrate on the '“parsing lessons” rather than the “request sending”.
So I gave this a try. and please feel free to not feel obligated to continue on with this, I was hoping that the easy part would be connecting to the API and the hard part would be me figuring out how to parse all my data into lessons lol. but if you feel up for it, this is what I tried, and i’m getting a “localhost says 0” error code. any ideas?
I think things may get really difficult from here. If you want to develop your tool to be used from a web browser you’d need to know if lingq’s API is suited for that environment:
does it support CORS
or does it support jsonp?
I tried your code and had problems with those topics.
So let’s get one step back: How to request something from lingq’s API?
Something that is not explicitly mentioned in the docs is authentication and authorization,
I guess you should send a cookie, because I can send requests (see pic related) from the chao/RESTClient addon only if I log in the site, otherwise it responds with:
{“detail”:“Authentication credentials were not provided.”}
Once you figure things out, then I’d recommend using a scripting language like python, I think I’ve read people from lingq attempting to upload lessons with scripts written with that.