Created
May 19, 2011 19:43
-
-
Save lperichon/981559 to your computer and use it in GitHub Desktop.
ajax call to the api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "POST", | |
beforeSend: function(xhr) {xhr.setRequestHeader("X-SpreeAPIKey", "e70bbc90dabc7ec32f39649878f4e38c509ddc3f")}, | |
url: "http://localhost:3000/api/friends", | |
dataType: "json", | |
data: "friend[first_name]=Luis&friend[last_name]=Perichon", | |
success: function(msg){ | |
alert( "Data Saved: " + msg ); | |
} | |
}); | |
Optional parameters: | |
first_name | |
last_name | |
city | |
state | |
country | |
facebook_id | |
birth_day | |
birth_month | |
birth_year | |
anniversary_day | |
anniversary_month | |
anniversary_year | |
gender_id | |
1 = male | |
2 = female | |
relationship_type_id | |
1 = Girlfriend | |
2 = Boyfriend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "POST", | |
beforeSend: function(xhr) {xhr.setRequestHeader("X-ThoughtfulAppKey", "03b1967b7717cc4358dd4062a7e28d6cdc6d95b3")}, | |
url: "http://localhost:3000/api/users", | |
dataType: "json", | |
data: "user[email][email protected]&user[first_name]=Luis&user[last_name]=Perichon&access_token=179204735427503|2.w_AhOCd6WnHi2tNZo7_QoA__.3600.1294419600-722198336|6yBpHjHtf3U9OMDeSJT4yFc1cnA&invite_token=f7d3e0fa84ec2028e938bf532a522597fd5e3f64", | |
success: function(msg){ | |
alert( "Data Saved: " + msg ); | |
} | |
}); | |
Response: | |
{ "user":{ "api_key":"03b1967b7717cc4358dd4062a7e28d6cdc6d95b3", "email":"[email protected]", "facebook_id":722198336, "first_name":"Luis", "id":2, "last_name":"Perichon", "bill_address":{ "address1":"Gurruchaga 2309 10A", "address2":null, "city":"Buenos Aires", "firstname":"Luis", "id":17, "lastname":"Perichon", "phone":"4831-0908", "state_name":"Capital Federal", "zipcode":"1425", "country":{ "id":9, "name":"Argentina" } } } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "GET", | |
beforeSend: function(xhr) {xhr.setRequestHeader("X-SpreeAPIKey", "e70bbc90dabc7ec32f39649878f4e38c509ddc3f")}, | |
url: "http://localhost:3000/api/friends", | |
dataType: "json" | |
}); | |
Response: | |
[ | |
{"friend":{"city":"","facebook_id":1092903782,"first_name":"Adriana","id":607,"last_name":"Bruer","state":"","birth_date":"1978-06-13","anniversary_date":null,"gender_name":"Female","relationship_type_name":"Girlfriend"}}, | |
{"friend":{"city":"","facebook_id":1203411323,"first_name":"Adriana","id":610,"last_name":"Gil","state":"","birth_date":null,"anniversary_date":null,"gender_name":"Female","relationship_type_name":"Family"}}, | |
{"friend":{"city":"","facebook_id":901635653,"first_name":"Ale","id":586,"last_name":"Acosta","state":"","birth_date":"1982-01-18","anniversary_date":null,"gender_name":"Female","relationship_type_name":"Friend"}}, | |
{"friend":{"city":"Orlando","facebook_id":749577182,"first_name":"Ana","id":427,"last_name":"Hirthe","state":"Florida","birth_date":"1980-03-25","anniversary_date":"2011-04-04","gender_name":"Female","relationship_type_name":"Other"}}, | |
{"friend":{"city":"","facebook_id":611244570,"first_name":"Agus","id":609,"last_name":"Muriago","state":"","birth_date":"1981-04-21","anniversary_date":null,"gender_name":"Female","relationship_type_name":null}}, | |
{"friend":{"city":"","facebook_id":1446323344,"first_name":"A. Mauricio","id":587,"last_name":"Castillo","state":"","birth_date":"1978-10-18","anniversary_date":null,"gender_name":"Male","relationship_type_name":null}}, | |
{"friend":{"city":"","facebook_id":511583390,"first_name":"Aaron","id":612,"last_name":"Zajonc","state":"","birth_date":null,"anniversary_date":null,"gender_name":"Male","relationship_type_name":null}}, | |
{"friend":{"city":"Seattle","facebook_id":null,"first_name":"Pepe","id":614,"last_name":"Le Pu","state":"Washington","birth_date":null,"anniversary_date":null,"gender_name":null,"relationship_type_name":null}}, | |
{"friend":{"city":"Seattle","facebook_id":765419024,"first_name":"Natalia","id":367,"last_name":"Gil","state":"Washington","birth_date":"0000-11-30","anniversary_date":null,"gender_name":"Female","relationship_type_name":null}}, | |
{"friend":{"city":null,"facebook_id":1481856996,"first_name":"Anto","id":618,"last_name":"Iezzi","state":null,"birth_date":"1982-12-13","anniversary_date":null,"gender_name":"Female","relationship_type_name":null}} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "POST", | |
beforeSend: function(xhr) {xhr.setRequestHeader("X-SpreeAPIKey", "e70bbc90dabc7ec32f39649878f4e38c509ddc3f")}, | |
url: "http://localhost:3000/api/friends/3/tastes", | |
dataType: "json", | |
data: "taste[data]=asdf", | |
success: function(msg){ | |
alert( "Data Saved: " + msg ); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "POST", | |
beforeSend: function(xhr) {xhr.setRequestHeader("X-ThoughtfulAppKey", "03b1967b7717cc4358dd4062a7e28d6cdc6d95b3")}, | |
url: "http://localhost:3000/api/user_sessions", | |
dataType: "json", | |
data: "access_token=179204735427503|2.w_AhOCd6WnHi2tNZo7_Qolanguage detected by filenaA__.3600.1294419600-722198336|6yBpHjHtf3U9OMDeSJT4yFc1cnA", | |
success: function(msg){ | |
alert( "Data Saved: " + msg ); | |
} | |
}); | |
Response: | |
{ "user":{ "api_key":"03b1967b7717cc4358dd4062a7e28d6cdc6d95b3", "email":"[email protected]", "facebook_id":722198336, "first_name":"Luis", "id":2, "last_name":"Perichon", "bill_address":{ "address1":"Gurruchaga 2309 10A", "address2":null, "city":"Buenos Aires", "firstname":"Luis", "id":17, "lastname":"Perichon", "phone":"4831-0908", "state_name":"Capital Federal", "zipcode":"1425", "country":{ "id":9, "name":"Argentina" } } } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment