I get 401 Unauthorized when I use this example code with my API key of course.
On Apr 15, 6:08 am, siggy <andrewseig...@gmail.com> wrote: > Hi there, > > Some of the @anywhere sample code in the "Working with the current > user" section required some tweaks to get working. > > The text specifies a User Callback function but the sample code does > not. > > Also, thetwttr.anywhere() function does not appear to work with an > API key, instead I specify it with the anywhere.js file. > > Here is a modified code snippet that appears to work: > > //var anywhereApiKey = "abcdefghi-123"; > //twttr.anywhere(anywhereApiKey, "1.0.0", > onAnywhereLoad);twttr.anywhere(onAnywhereLoad); > function onAnywhereLoad(twitter) > { > // Conditionally display theConnectButton based on current logged > in state: > if (twitter.isConnected) > { > twitter.User.current(user_callback); > } > else > { > twitter("#twitter-connect-placeholder").connectButton(); > } > > }; > > function user_callback(currentUser) > { > screenName = currentUser.data('screen_name'); > profileImage = currentUser.data('profile_image_url'); > profileImageTag = "<img src='" + profileImage + "'/>"; > > $('#twitter-connect-placeholder').innerHTML = "Logged in as " + > profileImageTag + " " + screenName; > > }; > > Thanks, > Andrew > twitter.com/siggy_sf