I was also facing the same issue before....it was sorted now by
properly encoding the tweet message we send. Please see the code below
done in Flex.


public function getSignedURI( method:String, url:String,
postData:String = "" ):String
                {

                        if( method.toUpperCase() != "GET" && 
method.toUpperCase() !=
"POST" )
                        {
                                throw new ArgumentError("Invalid method passed. 
Only GET and POST
supported");
                        }
                        if( url.length == 0 )
                        {
                                throw new ArgumentError("Empty url passed");
                        }
                        if( consumerKey.length == 0 )
                        {
                                throw new ArgumentError("consumerKey property 
not set");
                        }
                        if( _consumerSecret.length == 0 )
                        {
                                throw new ArgumentError("consumerSecret 
property not set");
                        }
                        var timeStamp:String = Math.round( new Date().getTime() 
/
1000 ).toString();
                        var nonce:String = Math.round(Math.random() * 99999 
).toString();

                         var args:Array = [];
                         if( _usePinWorkflow )
                        {
                         args.push({name: "oauth_callback", value: "oob"});
                        }
             args.push({name: "oauth_consumer_key", value:
consumerKey});
             args.push({name: "oauth_nonce", value: nonce});
             args.push({name: "oauth_signature_method", value: "HMAC-
SHA1"});
             args.push({name: "oauth_timestamp", value: timeStamp});
             args.push({name: "oauth_version", value: "1.0"});

                        if( _accessToken.length )
                        {
                                  args.push({name: "oauth_token", value: 
_accessToken});
                        }
                        else if( _authorizationToken.length )
                        {
                                  args.push({name: "oauth_token", value:
_authorizationToken});
                        }
                        if( _accessPin )
                        {
                                args.push({name: "oauth_verifier", value: 
_accessPin.toString
()});
                        }
                        if(method.toUpperCase() == "POST" && postData.length)
                        {

                                        args.push({name: "status", value:  
encode(postData)});
                        }
            args.sortOn("name");
            var n:int = args.length;
            var vars:String = "";
            for (var i:int = 0; i < n; i++)
            {
                if (args[i]["name"] != "_method")
                {
                    vars += args[i]["name"]+"="+args[i]["value"];
                    if (i != n-1)
                        vars += "&";
                }
            }
            var signString:String = method.toUpperCase() +"&" +
encodeURIComponent(url) + "&" + encodeURIComponent(vars);
            var hmac:HMAC =  Crypto.getHMAC("sha1");
            var key:ByteArray = Hex.toArray( Hex.fromString
(encodeURIComponent(_consumerSecret) + "&" + encodeURIComponent
(_accessTokenSecret)));
            var data:ByteArray = Hex.toArray( Hex.fromString
( signString ) );
            var sha:String = Base64.encodeByteArray( hmac.compute
( key, data ) );
            vars += "&oauth_signature="+encodeURIComponent(sha);
            trace ("Returned "+vars )
            return vars;
                }

Reply via email to