Skip to content

Instantly share code, notes, and snippets.

I am trying to switch from apache to nginx. for my wordpress and vanillaforums setup.
Essentially I need the wordpress rewrite to work correctly with vanilla forums
rewrite.
I have gist'd the apache rewrite I'm trying to emulate and
my current nginx config.
get '/user' do
foursquare = Foursquare.new
response = foursquare.request '/v1/user.json', :get
result = response.body
body = JSON.parse(result)
user = body['user']
return user['firstname'] # works
get '/callback' do
@newuser = Foursquare.prepare_user
if @newuser.exists?
redirect '/user'
else
User.save
end
end
def prepare_user
foursquare = Foursquare.new #instatiate
response = foursquare.request '/v1/user.json', :get #api method
result = response.body
body = JSON.parse(result)
user = body['user'] #parse response and make user variable
#this is where it gets hairy. how should I construct this hash so that I can easily pull out the uid param for verifification
<?php
$url = "http://search.twitter.com/search.json?q=from:kylemac";
$contents = file_get_contents($url);
$contents = utf8_encode($contents);
$results = json_decode($contents);
echo '<pre>';