Re: [twitter-dev] Re: xAuth Request gives Error from samsung tv maple browser

2010-12-09 Thread umamahesh G.
HI Tom

Thank you very much for Your kind Support.Still i could not able to get
Response from Twitter from firefox and samsung TV app.
But it is working in Safari.Here i am sending the clean  code as an
attachment please help me out where the hurdle exist.
If you make it work in firefox surely works in samsung TV. So please help me
Tom.
Thanks.

On Tue, Dec 7, 2010 at 3:52 PM, Tom van der Woerdt i...@tvdw.eu wrote:

 That code is really a mess, but I think I found a few issues and solved
 them. I'm not sure about the Signature itself, but the Base String is fine
 now.

 I've attached a new version of your .html file. I won't paste the code
 here because it may break the code.

 Tom

 PS: I really recommend keeping your code clean. This file is a mess.




 On 12/7/10 6:07 AM, umamahesh G. wrote:

 HI Tom,

 Thanks for you kind support.I had all required privileges from twitter
 for my app.The thing is i can able to post the message from safari but
 same code not working in firefox,IE as well as samsung Tv.Please help me
 out from this problem.I tried maximum ways still i don't have any
 solution.

 On Tue, Dec 7, 2010 at 5:48 AM, Bess bess...@gmail.com
 mailto:bess...@gmail.com wrote:

I am interested in solving this too.

Let's say Samsung TV is same as desk top. You should be able to use
xAuth.

You need to create a new Twitter app to get Consumer key and Consumer
secret. Make sure you select client method and read/write.

On Dec 6, 1:23 am, umamahesh G. g.umamahesh...@gmail.com
 mailto:g.umamahesh...@gmail.com wrote:
  HI Tom,
 
  Thanks for your support. I am using javascript for samsung TV
Applicaiton
  not for normal browser so there is no way to know about keys and
secret
  key.Actually Samsung SDK uses Maple browser and  application runs
on  this
  browser.
 
  I hope you help me out from this issue.
 
  Please find the below code.
 
  html
  head
  lt;script type =text/Javascript language=Javascript
  src=sha1.js/script
  lt;script type=text/javascript charset=utf-8
 
  /*To authorize on Twitter API through xAuth, you need HMAC-SHA1
  I'm using the following lib for that:http://jssha.sourceforge.net
http://jssha.sourceforge.net/
  Make sure you have sha.js included!Also, you need to email
  a...@twitter.comto get xAuth access
  I cannot do that for you - seehttp://dev.twitter.com/pages/xauth
http://dev.twitter.com/pages/xauth
  cross-domain XHRs only work on file:// protocol pages
  use PhoneGap!
   */
 
  var TwitterApiRequest = function() {
  this.nonce = this.generateNonce();
  this.timestamp = this.getUTCtimestamp();
 
  this.postBody = null;
  this.signature = null;
  this.signatureBaseString = null;
  this.consumerSecret=MY consumerSecret ;
 
  }
 
  TwitterApiRequest.prototype.generateNonce = function () {
  var nonce = [];
  var length = 6; // arbitrary - looks like a good length
 
  for (length; length  0; length--)
 
nonce.push1+Math.random())*0x1)|0).toString(16).substring(1));
 
  return nonce.join();
 
  }
 
  // could possibly do without UTC, but here we are
  TwitterApiRequest.prototype.getUTCtimestamp = function ()
  {
  //var currentTime = new Date();
  //var currentUTCTimeInSecs =
  Math.floor(Date.parse(currentTime.toUTCString()) / 1000);
  //return currentUTCTimeInSecs;
  return (new Date((new Date).toUTCString())).getTime() / 1000;
 
  }
 
  // don't forget trailing !
  //TwitterApiRequest.prototype.consumerSecret =
  MY consumerSecret ;
 
  TwitterApiRequest.prototype.signatureBaseStringTemplate = POST +
  https%3A%2F%2Fapi.twitter.com http://2fapi.twitter.com/ 
 http://2fapi.twitter.com/
  http://2fapi.twitter.com/%2Foauth%2Faccess_token
  + // oauth_path
  oauth_consumer_key%3DMY CONSUMER KEY%26 +
  oauth_nonce%3D + {{ nonce }} + %26 +
  oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D + {{
time }} +
  %26 +
  oauth_version%3D1.0%26 +
  x_auth_mode%3Dclient_auth%26 +
  x_auth_password%3D + {{ password }} + %26 +
  x_auth_username%3D + {{ username }}
 
  TwitterApiRequest.prototype.authHeaderTemplate = OAuth  +
  oauth_nonce=\ + {{ nonce }} + \,  +
  oauth_signature_method=\HMAC-SHA1\,  +
  oauth_timestamp=\ + {{ time }} + \,  +
  oauth_consumer_key=\MY CONSUMER KEY\,  +
  oauth_signature=\ + {{ signature }} + \,  +
  oauth_version=\1.0\;
 
  TwitterApiRequest.prototype.processCredentials = function (user,
pw) {
  this.signatureBaseString = this.signatureBaseStringTemplate
  .split({{ nonce }}).join(this.nonce)
  .split({{ time }}).join(this.timestamp)
  .split({{ password
 
  }}).join(encodeURIComponent(pw))
  .split({{ username
  

Re: [twitter-dev] Re: xAuth Request gives Error from samsung tv maple browser

2010-12-07 Thread Tom van der Woerdt
That code is really a mess, but I think I found a few issues and solved 
them. I'm not sure about the Signature itself, but the Base String is 
fine now.


I've attached a new version of your .html file. I won't paste the code 
here because it may break the code.


Tom

PS: I really recommend keeping your code clean. This file is a mess.



On 12/7/10 6:07 AM, umamahesh G. wrote:

HI Tom,
Thanks for you kind support.I had all required privileges from twitter
for my app.The thing is i can able to post the message from safari but
same code not working in firefox,IE as well as samsung Tv.Please help me
out from this problem.I tried maximum ways still i don't have any solution.

On Tue, Dec 7, 2010 at 5:48 AM, Bess bess...@gmail.com
mailto:bess...@gmail.com wrote:

I am interested in solving this too.

Let's say Samsung TV is same as desk top. You should be able to use
xAuth.

You need to create a new Twitter app to get Consumer key and Consumer
secret. Make sure you select client method and read/write.

On Dec 6, 1:23 am, umamahesh G. g.umamahesh...@gmail.com
mailto:g.umamahesh...@gmail.com wrote:
  HI Tom,
 
  Thanks for your support. I am using javascript for samsung TV
Applicaiton
  not for normal browser so there is no way to know about keys and
secret
  key.Actually Samsung SDK uses Maple browser and  application runs
on  this
  browser.
 
  I hope you help me out from this issue.
 
  Please find the below code.
 
  html
  head
  lt;script type =text/Javascript language=Javascript
  src=sha1.js/script
  lt;script type=text/javascript charset=utf-8
 
  /*To authorize on Twitter API through xAuth, you need HMAC-SHA1
  I'm using the following lib for that:http://jssha.sourceforge.net
http://jssha.sourceforge.net/
  Make sure you have sha.js included!Also, you need to email
  a...@twitter.comto get xAuth access
  I cannot do that for you - seehttp://dev.twitter.com/pages/xauth
http://dev.twitter.com/pages/xauth
  cross-domain XHRs only work on file:// protocol pages
  use PhoneGap!
   */
 
  var TwitterApiRequest = function() {
  this.nonce = this.generateNonce();
  this.timestamp = this.getUTCtimestamp();
 
  this.postBody = null;
  this.signature = null;
  this.signatureBaseString = null;
  this.consumerSecret=MY consumerSecret ;
 
  }
 
  TwitterApiRequest.prototype.generateNonce = function () {
  var nonce = [];
  var length = 6; // arbitrary - looks like a good length
 
  for (length; length  0; length--)
 
nonce.push1+Math.random())*0x1)|0).toString(16).substring(1));
 
  return nonce.join();
 
  }
 
  // could possibly do without UTC, but here we are
  TwitterApiRequest.prototype.getUTCtimestamp = function ()
  {
  //var currentTime = new Date();
  //var currentUTCTimeInSecs =
  Math.floor(Date.parse(currentTime.toUTCString()) / 1000);
  //return currentUTCTimeInSecs;
  return (new Date((new Date).toUTCString())).getTime() / 1000;
 
  }
 
  // don't forget trailing !
  //TwitterApiRequest.prototype.consumerSecret =
  MY consumerSecret ;
 
  TwitterApiRequest.prototype.signatureBaseStringTemplate = POST +
  https%3A%2F%2Fapi.twitter.com http://2fapi.twitter.com/
  http://2fapi.twitter.com/%2Foauth%2Faccess_token
  + // oauth_path
  oauth_consumer_key%3DMY CONSUMER KEY%26 +
  oauth_nonce%3D + {{ nonce }} + %26 +
  oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D + {{
time }} +
  %26 +
  oauth_version%3D1.0%26 +
  x_auth_mode%3Dclient_auth%26 +
  x_auth_password%3D + {{ password }} + %26 +
  x_auth_username%3D + {{ username }}
 
  TwitterApiRequest.prototype.authHeaderTemplate = OAuth  +
  oauth_nonce=\ + {{ nonce }} + \,  +
  oauth_signature_method=\HMAC-SHA1\,  +
  oauth_timestamp=\ + {{ time }} + \,  +
  oauth_consumer_key=\MY CONSUMER KEY\,  +
  oauth_signature=\ + {{ signature }} + \,  +
  oauth_version=\1.0\;
 
  TwitterApiRequest.prototype.processCredentials = function (user,
pw) {
  this.signatureBaseString = this.signatureBaseStringTemplate
  .split({{ nonce }}).join(this.nonce)
  .split({{ time }}).join(this.timestamp)
  .split({{ password
 
  }}).join(encodeURIComponent(pw))
  .split({{ username
  }}).join(encodeURIComponent(user));
 
  this.postBody = x_auth_mode=client_auth +
  x_auth_password= + encodeURIComponent(pw) +  +
  x_auth_username= + encodeURIComponent(user);
 
  }
 
  TwitterApiRequest.prototype.sign = function ()
  {
  //var shaObj = new jsSHA(base_string, ASCII);
  //var oauth_signature = shaObj.getHMAC(consumersecret, ASCII,
B64);
  alert(this.signatureBaseString 

[twitter-dev] Re: xAuth Request gives Error from samsung tv maple browser

2010-12-06 Thread Bess
I am interested in solving this too.

Let's say Samsung TV is same as desk top. You should be able to use
xAuth.

You need to create a new Twitter app to get Consumer key and Consumer
secret. Make sure you select client method and read/write.

On Dec 6, 1:23 am, umamahesh G. g.umamahesh...@gmail.com wrote:
 HI Tom,

 Thanks for your support. I am using javascript for samsung TV Applicaiton
 not for normal browser so there is no way to know about keys and secret
 key.Actually Samsung SDK uses Maple browser and  application runs on  this
 browser.

 I hope you help me out from this issue.

 Please find the below code.

 html
 head
 lt;script type =text/Javascript language=Javascript
 src=sha1.js/script
 lt;script type=text/javascript charset=utf-8

 /*To authorize on Twitter API through xAuth, you need HMAC-SHA1
 I'm using the following lib for that:http://jssha.sourceforge.net
 Make sure you have sha.js included!Also, you need to email
 a...@twitter.comto get xAuth access
 I cannot do that for you - seehttp://dev.twitter.com/pages/xauth
 cross-domain XHRs only work on file:// protocol pages
 use PhoneGap!
  */

 var TwitterApiRequest = function() {
 this.nonce = this.generateNonce();
 this.timestamp = this.getUTCtimestamp();

 this.postBody = null;
 this.signature = null;
 this.signatureBaseString = null;
 this.consumerSecret=MY consumerSecret ;

 }

 TwitterApiRequest.prototype.generateNonce = function () {
 var nonce = [];
 var length = 6; // arbitrary - looks like a good length

 for (length; length  0; length--)
 nonce.push1+Math.random())*0x1)|0).toString(16).substring(1));

 return nonce.join();

 }

 // could possibly do without UTC, but here we are
 TwitterApiRequest.prototype.getUTCtimestamp = function ()
 {
 //var currentTime = new Date();
 //var currentUTCTimeInSecs =
 Math.floor(Date.parse(currentTime.toUTCString()) / 1000);
 //return currentUTCTimeInSecs;
 return (new Date((new Date).toUTCString())).getTime() / 1000;

 }

 // don't forget trailing !
 //TwitterApiRequest.prototype.consumerSecret =
 MY consumerSecret ;

 TwitterApiRequest.prototype.signatureBaseStringTemplate = POST +
 https%3A%2F%2Fapi.twitter.com
 http://2fapi.twitter.com/%2Foauth%2Faccess_token
 + // oauth_path
 oauth_consumer_key%3DMY CONSUMER KEY%26 +
 oauth_nonce%3D + {{ nonce }} + %26 +
 oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D + {{ time }} +
 %26 +
 oauth_version%3D1.0%26 +
 x_auth_mode%3Dclient_auth%26 +
 x_auth_password%3D + {{ password }} + %26 +
 x_auth_username%3D + {{ username }}

 TwitterApiRequest.prototype.authHeaderTemplate = OAuth  +
 oauth_nonce=\ + {{ nonce }} + \,  +
 oauth_signature_method=\HMAC-SHA1\,  +
 oauth_timestamp=\ + {{ time }} + \,  +
 oauth_consumer_key=\MY CONSUMER KEY\,  +
 oauth_signature=\ + {{ signature }} + \,  +
 oauth_version=\1.0\;

 TwitterApiRequest.prototype.processCredentials = function (user, pw) {
 this.signatureBaseString = this.signatureBaseStringTemplate
 .split({{ nonce }}).join(this.nonce)
 .split({{ time }}).join(this.timestamp)
 .split({{ password

 }}).join(encodeURIComponent(pw))
 .split({{ username
 }}).join(encodeURIComponent(user));

 this.postBody = x_auth_mode=client_auth +
 x_auth_password= + encodeURIComponent(pw) +  +
 x_auth_username= + encodeURIComponent(user);

 }

 TwitterApiRequest.prototype.sign = function ()
 {
 //var shaObj = new jsSHA(base_string, ASCII);
 //var oauth_signature = shaObj.getHMAC(consumersecret, ASCII, B64);
 alert(this.signatureBaseString :+this.signatureBaseString);
 var hmacGen = new jsSHA(this.signatureBaseString,ASCII);
 this.signature = hmacGen.getHMAC(this.consumerSecret,ASCII,B64)+%3D;

 this.authHeader = this.authHeaderTemplate
 .split({{ nonce }}).join(this.nonce)
 .split({{ time }}).join(this.timestamp)
 .split({{ signature }}).join(this.signature);

 }

 function ajaxrequest()
 {
 var authorizeRequest = new TwitterApiRequest();
 authorizeRequest.processCredentials(suyambu.vikn...@gmail.com,
 simcard00);
 authorizeRequest.sign();

 var twitterUrl = 'https://api.twitter.com/oauth/access_token?'+
 authorizeRequest.postBody;

 var req = new XMLHttpRequest();
 alert(this.postBody : +authorizeRequest.postBody);
 alert(header :+authorizeRequest.authHeader);
 // sync for testing purposes, not required
 req.open('POST', twitterUrl, false);
 req.setRequestHeader(Authorization, authorizeRequest.authHeader);
 req.send();
 alert(Response :+req.responseText);
 // should be 200
 //console.log(req.status);
 alert(Status :+req.status);
 // should look like:
 //
 oauth_token=HERE-IS-MY-AWESOME-TOKENoauth_token_secret=THIS-IS-MY-TOKEN-SECRET
 // user_id=007screen_name=JamesBondx_auth_expires=0
 //console.log(req.responseText);

 }

 /script
 /head

 body onLoad=ajaxrequest();

 /body
 /html

 On Sat, Dec 4, 2010 at 4:35 PM, Tom van der Woerdt i...@tvdw.eu wrote:



  You really shouldn't implement xAuth in JavaScript for obvious reasons,
  like how impossible it is to keep your keys secret.

  Tom

  On 12/4/10 6:19 AM, 

Re: [twitter-dev] Re: xAuth Request gives Error from samsung tv maple browser

2010-12-06 Thread umamahesh G.
HI Tom,

Thanks for you kind support.I had all required privileges from twitter for
my app.The thing is i can able to post the message from safari but same
code not working in firefox,IE as well as samsung Tv.Please help me out from
this problem.I tried maximum ways still i don't have any solution.

On Tue, Dec 7, 2010 at 5:48 AM, Bess bess...@gmail.com wrote:

 I am interested in solving this too.

 Let's say Samsung TV is same as desk top. You should be able to use
 xAuth.

 You need to create a new Twitter app to get Consumer key and Consumer
 secret. Make sure you select client method and read/write.

 On Dec 6, 1:23 am, umamahesh G. g.umamahesh...@gmail.com wrote:
  HI Tom,
 
  Thanks for your support. I am using javascript for samsung TV Applicaiton
  not for normal browser so there is no way to know about keys and secret
  key.Actually Samsung SDK uses Maple browser and  application runs on
  this
  browser.
 
  I hope you help me out from this issue.
 
  Please find the below code.
 
  html
  head
  lt;script type =text/Javascript language=Javascript
  src=sha1.js/script
  lt;script type=text/javascript charset=utf-8
 
  /*To authorize on Twitter API through xAuth, you need HMAC-SHA1
  I'm using the following lib for that:http://jssha.sourceforge.net
  Make sure you have sha.js included!Also, you need to email
  a...@twitter.comto get xAuth access
  I cannot do that for you - seehttp://dev.twitter.com/pages/xauth
   cross-domain XHRs only work on file:// protocol pages
  use PhoneGap!
   */
 
  var TwitterApiRequest = function() {
  this.nonce = this.generateNonce();
  this.timestamp = this.getUTCtimestamp();
 
  this.postBody = null;
  this.signature = null;
  this.signatureBaseString = null;
  this.consumerSecret=MY consumerSecret ;
 
  }
 
  TwitterApiRequest.prototype.generateNonce = function () {
  var nonce = [];
  var length = 6; // arbitrary - looks like a good length
 
  for (length; length  0; length--)
  nonce.push1+Math.random())*0x1)|0).toString(16).substring(1));
 
  return nonce.join();
 
  }
 
  // could possibly do without UTC, but here we are
  TwitterApiRequest.prototype.getUTCtimestamp = function ()
  {
  //var currentTime = new Date();
  //var currentUTCTimeInSecs =
  Math.floor(Date.parse(currentTime.toUTCString()) / 1000);
  //return currentUTCTimeInSecs;
  return (new Date((new Date).toUTCString())).getTime() / 1000;
 
  }
 
  // don't forget trailing !
  //TwitterApiRequest.prototype.consumerSecret =
  MY consumerSecret ;
 
  TwitterApiRequest.prototype.signatureBaseStringTemplate = POST +
  https%3A%2F%2Fapi.twitter.com http://2fapi.twitter.com/
  http://2fapi.twitter.com/%2Foauth%2Faccess_token
   + // oauth_path
  oauth_consumer_key%3DMY CONSUMER KEY%26 +
  oauth_nonce%3D + {{ nonce }} + %26 +
  oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D + {{ time }}
 +
  %26 +
  oauth_version%3D1.0%26 +
  x_auth_mode%3Dclient_auth%26 +
  x_auth_password%3D + {{ password }} + %26 +
  x_auth_username%3D + {{ username }}
 
  TwitterApiRequest.prototype.authHeaderTemplate = OAuth  +
  oauth_nonce=\ + {{ nonce }} + \,  +
  oauth_signature_method=\HMAC-SHA1\,  +
  oauth_timestamp=\ + {{ time }} + \,  +
  oauth_consumer_key=\MY CONSUMER KEY\,  +
  oauth_signature=\ + {{ signature }} + \,  +
  oauth_version=\1.0\;
 
  TwitterApiRequest.prototype.processCredentials = function (user, pw) {
  this.signatureBaseString = this.signatureBaseStringTemplate
  .split({{ nonce }}).join(this.nonce)
  .split({{ time }}).join(this.timestamp)
  .split({{ password
 
  }}).join(encodeURIComponent(pw))
  .split({{ username
  }}).join(encodeURIComponent(user));
 
  this.postBody = x_auth_mode=client_auth +
  x_auth_password= + encodeURIComponent(pw) +  +
  x_auth_username= + encodeURIComponent(user);
 
  }
 
  TwitterApiRequest.prototype.sign = function ()
  {
  //var shaObj = new jsSHA(base_string, ASCII);
  //var oauth_signature = shaObj.getHMAC(consumersecret, ASCII, B64);
  alert(this.signatureBaseString :+this.signatureBaseString);
  var hmacGen = new jsSHA(this.signatureBaseString,ASCII);
  this.signature =
 hmacGen.getHMAC(this.consumerSecret,ASCII,B64)+%3D;
 
  this.authHeader = this.authHeaderTemplate
  .split({{ nonce }}).join(this.nonce)
  .split({{ time }}).join(this.timestamp)
  .split({{ signature }}).join(this.signature);
 
  }
 
  function ajaxrequest()
  {
  var authorizeRequest = new TwitterApiRequest();
  authorizeRequest.processCredentials(suyambu.vikn...@gmail.com,
  simcard00);
  authorizeRequest.sign();
 
  var twitterUrl = 'https://api.twitter.com/oauth/access_token?'+
  authorizeRequest.postBody;
 
  var req = new XMLHttpRequest();
  alert(this.postBody : +authorizeRequest.postBody);
  alert(header :+authorizeRequest.authHeader);
  // sync for testing purposes, not required
  req.open('POST', twitterUrl, false);
  req.setRequestHeader(Authorization, authorizeRequest.authHeader);
  req.send();
  alert(Response :+req.responseText);
  // should be 200