Thursday, August 26, 2010

Using Twitter's @anywhere Service on Localhost (and with Web Matrix/IIS Express)

Here is the trick to get Twitter's @anywhere service (http://dev.twitter.com/anywhere) working on your localhost website for development and testing.

1) Don't put a call back url when you register your app.
2) On the link below where you register the call back url for your app, click the add domain link.
3) Add either localhost, 127.0.0.1, or both (may not take 127.0.0.1)
4) In your javascript specify the callback url (localhost, 127.0.0.0/auth.cshtml, whatever. I didn't test this but I think you might even be able to enter ports in (localhost:8080). I ended up setting my web server to run on port 80 (default) so I didn't need to add any ports. If you can't enter ports, you might be stuck having to run your dev web server on port 80 or 8080.

Done. No editing hosts files, nada. Why is this so easy and not documented? I think it is because of a recent change on Twitter's end to loosen things up a bit so you can test your applications. For deployment, you may need to actually enter a call back url for your application. I don't thinks so, but test.

For me I'm working with Web Matrix, and I wanted iis express to run on Port 80. Three things.

1) Turn off/stop your default non-IIS Express web server (apache, dev version of IIS full) so you don't get any conflicts.
2) navigate to where the web matrix exe file is located by opening up a console by typing cmd in the start run menu, then navigate to the path by typing something like cd: c:\mypath\. Once there you can run iis express from the command line (only way right now to specify a port).

type something like iisexpress /path:c\mywebpath\mywebsite\ /port:80

3) Right now you can't have any spaces in the path name. I figure that will be fixed in the next beta or the final release.

No comments: