Thanks for your help with this. I have resolved the issue.
It was not obvious to me that when changing the application access level (I changed this from Read Only to Read, write, and direct messages) that the keys needed to be regenerated. So in effect the problem was that I only had read only access - which explains why I could access the interface to read the user details and filtered stream but could not Tweet.
I regenerated all keys and plugged them into the program and it now seems to work fine.
(For info, one other thing I noticed was that the 401 can be caused if the Callback URL is not filled in)
It was not obvious to me that when changing the application access level (I changed this from Read Only to Read, write, and direct messages) that the keys needed to be regenerated. So in effect the problem was that I only had read only access - which explains why I could access the interface to read the user details and filtered stream but could not Tweet.
I regenerated all keys and plugged them into the program and it now seems to work fine.
(For info, one other thing I noticed was that the 401 can be caused if the Callback URL is not filled in)