I was going through this blog. My JavaScript senses tingled and I thought I will slightly modify the existing code.
Have a look at it here and the code here.
Thanks ashbotandsparki!
I was going through this blog. My JavaScript senses tingled and I thought I will slightly modify the existing code.
Have a look at it here and the code here.
Thanks ashbotandsparki!
In the earlier post we saw the need for OAuth. Let me explain it a little more.
Steve wants to get some money from his bank account. He calls his son Bob, gives him his Visa Card and the pin number and asks him to withdraw some money for him from the ATM. Don’t you think Steve is taking a risk here?
Now imagine yourself giving your twitter username and password to a third party application so that they can tweet about your blog article on your behalf. Dont you think you are taking a risk here, just like Steve?
A better solution for Steve would be that he writes a cheque for the exact amount needed, puts his signature in the cheque and asks Bob to encash it from the bank. Now we all agree this is a far safer approach. This ensures that:
Similary instead of giving our credentials to a third party application, we can ask twitter to give the third party application an encrypted information ( or token ) of our twitter identity with restricted priviledges. This ensures that:
So, did you finally get how OAuth works? In my next post I will talk about how to use OAuth with Twitter.
As I had mentioned earlier here I finally got my python program to send a tweet! You can check it out here.
But before I get into what I did, let me give you a background on what it takes a python code to talk to twitter.
Many times we tweet or like or share content from other webpages, be it a WordPress blog or a game score which we want to boast about on Facebook. In all such cases there are three things involved:
A few years back, the user would type his Twitter username and password in the Application, which would then use the credentials of the user to send a tweet. Now, this obviously has flaws like:
To avoid this we need a different mechanism. The user needs to allow the Application to post/tweet on his account – without sharing the username and password to the Application! This is where OAuth comes into the picture. I will briefly talk about it my next post. I guess the entire discussion on how I got my python code to say hello on twitter will consume another three blog posts I guess 🙂
I am trying to write a python code to send out tweets! I will keep updating the status and if it works, the code as well! 🙂
I was going through ashbotandsparki quiz. ( Thanks ahsbotandsparki ! )
I thought I would help out a bit. The updated code can be found in my comment on the above mentioned post. You can also find it here.
What I basically did was:
Some of my friends were recently trying out to create a page where the user can drag and drop pieces of pseudo code and they need to check if his pseudo code is fine. The initial solution used was to check the order in which the lines of the pseudo code were placed. But this soon lead to problems, as we know there is no one unique solution to a problem.
What I implemented was to convert the pseudo code into a equivalent JavaScript code ( programatically ) and pass it to eval(). TaDa! It worked!
Recently I was helping some of my friends who were trying to execute a JavaScript code programmatically. The requirement was that the user can enter a JavaScript code in a textarea and click a button and the user should get the output on the screen. They had taken a longer route: take the code and send it to the server through ajax. Paste the code in a script tag of a dummy page and display the page as an iframe. Wow!
So I pitched in and suggested a simpler solution. Take the code and pass it to the eval(). Ensure you have a try,catch block to capture error messages as well. Worked like a charm! Of course, we had to ‘disable’ a few things in it like alert, prompts, etc. It was fun!