Posting on Twitter Problem

I have a problem with my Twitter posting code. Whenever I click on the twitter button, it says Bad argument in #1 gsub (String Expected, got table). Could anyone help me fix this problem?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local tweet = display.newImage("tweet.png")
        tweet.x = 80; tweet.y = 271
        tweet.xScale = .435; tweet.yScale = .435
        localGroup:insert(tweet)
        
        local function escape(s)
                        s = string.gsub(s, "([&=+%c])", function (c)
                                                        return string.format("%%%02X", string.byte(c))
                                        end)
                                s = string.gsub(s, " ", "+")
                        return s
                        end
                        tweetText = "I love Gun App for Nook! Check it out http://bit.ly/A8NmI6 #gunapp #ninjapigstudios"
                        local postBody = escape( tweetText )
                        local theNetwork = theNetwork or "twitter" -- twitter is default
                         
                        --local theString = string.gsub(message, "( )", "%%20")
                        
                        TwitterButtonRelease = function(event)
                                if theNetwork == theNetwork or "twitter" then
                                        system.openURL("http://twitter.com/intent/tweet?text="..postBody)
                                end
                        end
views:1914 update:2012/2/9 11:37:26
corona forums © 2003-2011