Permalink
Browse files

Foursquare plugin: Accomodate 4sq's new user and venue icon format, f…

…ix crawl
  • Loading branch information...
1 parent 8109a16 commit c97399d0779a78ad3653b98a2e6497eecbf2ca5a @ginatrapani ginatrapani committed Nov 19, 2012
View
17 webapp/plugins/foursquare/model/class.FoursquareCrawler.php
@@ -141,7 +141,7 @@ public function initializeInstanceUser($access_token, $owner_id) {
} else {
// If something went wrong note this in the log
$this->logger->logInfo("Error fetching ".$owner_id." ". $network."'s details from the foursquare API, ".
- "response was ".Utils::varDumpToString($user_details), __METHOD__.','.__LINE__);
+ "response was ".Utils::varDumpToString($user_details), __METHOD__.','.__LINE__);
}
// Return the user object
return $user_object;
@@ -187,7 +187,8 @@ private function parseUserDetails($details) {
$user_vals["user_name"] = isset($user_name) ? $user_name : 'email address withheld';
$user_vals["full_name"] = $details->response->user->firstName." ".$details->response->user->lastName;
$user_vals["user_id"] = $details->response->user->id;
- $user_vals["avatar"] = $details->response->user->photo;
+ $user_vals["avatar"] = $details->response->user->photo->prefix . "100x100" .
+ $details->response->user->photo->suffix;
$user_vals['url'] = 'http://www.foursquare.com/user/'.$details->response->user->id;
$user_vals["follower_count"] = 0;
$user_vals["location"] = $details->response->user->homeCity;
@@ -286,7 +287,9 @@ private function parseResults($checkins){
// The author full name is the name they gave foursquare
$post['author_fullname'] = $user->response->user->firstName." ".$user->response->user->lastName;
// The avatar is the one they have set on foursquare
- $post['author_avatar'] = $user->response->user->photo;
+ $post["author_avatar"] = $user->response->user->photo->prefix . "100x100" .
+ $user->response->user->photo->suffix;
+
// The author user id is there foursquare user ID
$post['author_user_id'] = $user->response->user->id;
// The date they checked in
@@ -360,7 +363,9 @@ private function parseResults($checkins){
// The author full name is the name they gave foursquare
$comment_store['author_fullname'] = $comment->user->firstName." ".$comment->user->lastName;
// The avatar is the one they have set on foursquare
- $comment_store['author_avatar'] = $comment->user->photo;
+ $comment_store["author_avatar"] = $comment->user->photo->prefix . "100x100" .
+ $comment->user->photo->suffix;
+
// The author user id is there foursquare user ID
$comment_store['author_user_id'] = $comment->user->id;
// The date they posted the comment
@@ -411,9 +416,11 @@ private function parseResults($checkins){
$places['place_type'] = $item->venue->categories[0]->name;
$places['name'] = $item->venue->name;
$places['full_name'] = $item->venue->name;
- $places['icon'] = $item->venue->categories[0]->icon;
+ $places['icon'] = $item->venue->categories[0]->icon->prefix.'64'.
+ $item->venue->categories[0]->icon->suffix;
$places['lat_lng'] = 'POINT('.$item->venue->location->lat." ".$item->venue->location->lng.')';
$places['map_image'] = $this->generateMap($item);
+
$place_dao->insertGenericPlace($places, 'foursquare');
}
View
5 webapp/plugins/foursquare/model/class.FoursquarePlugin.php
@@ -94,7 +94,10 @@ public function crawl() {
// Check the OAuth tokens we have are valid
try {
$logger->logInfo("About to initializeInstanceUser", __METHOD__.','.__LINE__);
- $crawler->initializeInstanceUser($access_token, $current_owner->id);
+ $user = $crawler->initializeInstanceUser($access_token, $current_owner->id);
+ if (isset($user) && $user instanceof User) {
+ $logger->logInfo("User initialized", __METHOD__.','.__LINE__);
+ }
// Get the data we want and store it in the database
$logger->logInfo("About to fetchInstanceUserCheckins", __METHOD__.','.__LINE__);
$crawler->fetchInstanceUserCheckins();
View
10 webapp/plugins/foursquare/tests/TestOfFoursquareCrawler.php
@@ -195,7 +195,7 @@ public function testFetchInstanceUserCheckins() {
// Check the fullname was set
$this->assertEqual($post->author_fullname, 'Bob Cats');
// Check the avatar was set
- $this->assertEqual($post->author_avatar, 'https://foursquare.com/img/blank_boy.png');
+ $this->assertEqual($post->author_avatar, 'https://foursquare.com/img/100x100/blank_boy.png');
// Check the author used id was set
$this->assertEqual($post->author_user_id, '113612142759476883204');
// Check the publication date was set
@@ -253,7 +253,7 @@ public function testFetchInstanceUserCheckins() {
// Check the fullname was set
$this->assertEqual($comment->author_fullname, 'Bob Cats');
// Check the avatar was set
- $this->assertEqual($comment->author_avatar, 'https://foursquare.com/img/blank_boy.png');
+ $this->assertEqual($comment->author_avatar, 'https://foursquare.com/img/100x100/blank_boy.png');
// Check the author used id was set
$this->assertEqual($comment->author_user_id, '113612142759476883204');
// Check the publication date was set
@@ -331,7 +331,7 @@ public function testFetchInstanceUserCheckinsFullArchive() {
// Check the fullname was set
$this->assertEqual($post->author_fullname, 'Bob Cats');
// Check the avatar was set
- $this->assertEqual($post->author_avatar, 'https://foursquare.com/img/blank_boy.png');
+ $this->assertEqual($post->author_avatar, 'https://foursquare.com/img/100x100/blank_boy.png');
// Check the author used id was set
$this->assertEqual($post->author_user_id, '113612142759476883204');
// Check the publication date was set
@@ -388,7 +388,7 @@ public function testFetchInstanceUserCheckinsFullArchive() {
// Check the fullname was set
$this->assertEqual($comment->author_fullname, 'Bob Cats');
// Check the avatar was set
- $this->assertEqual($comment->author_avatar, 'https://foursquare.com/img/blank_boy.png');
+ $this->assertEqual($comment->author_avatar, 'https://foursquare.com/img/100x100/blank_boy.png');
// Check the author used id was set
$this->assertEqual($comment->author_user_id, '113612142759476883204');
// Check the publication date was set
@@ -449,7 +449,7 @@ public function testFetchInstanceUserCheckinsFullArchive() {
// Check the fullname was set
$this->assertEqual($post->author_fullname, 'Bob Cats');
// Check the avatar was set
- $this->assertEqual($post->author_avatar, 'https://foursquare.com/img/blank_boy.png');
+ $this->assertEqual($post->author_avatar, 'https://foursquare.com/img/100x100/blank_boy.png');
// Check the author used id was set
$this->assertEqual($post->author_user_id, '113612142759476883204');
// Check the publication date was set
View
15 ...pp/plugins/foursquare/tests/testdata/checkins_4efa01068b81ef98d2e9cd0b-oauth_token=secret
@@ -20,7 +20,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",
@@ -104,7 +107,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/18127856",
@@ -124,7 +130,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/18127856",
View
5 webapp/plugins/foursquare/tests/testdata/users_113612142759476883204-oauth_token=secret
@@ -15,7 +15,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",
View
5 webapp/plugins/foursquare/tests/testdata/users_18127856-oauth_token=secret
@@ -15,7 +15,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",
View
5 webapp/plugins/foursquare/tests/testdata/users_self-oauth_token=secret
@@ -15,7 +15,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"relationship": "self",
View
5 webapp/plugins/foursquare/tests/testdata/users_self_checkins-oauth_token=secret
@@ -86,7 +86,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",
View
5 ...plugins/foursquare/tests/testdata/users_self_checkins-oauth_token=secret-afterTimestamp=0
@@ -86,7 +86,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",
View
5 ...ursquare/tests/testdata/users_self_checkins-oauth_token=secret-afterTimestamp=0-limit=250
@@ -86,7 +86,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",
View
5 webapp/plugins/foursquare/tests/testdata/users_self_checkins-oauth_token=secret-limit=250
@@ -86,7 +86,10 @@
"id": "113612142759476883204",
"firstName": "Bob",
"lastName": "Cats",
- "photo": "https://foursquare.com/img/blank_boy.png",
+ "photo": {
+ "prefix": "https://foursquare.com/img/",
+ "suffix": "/blank_boy.png"
+ },
"gender": "none",
"homeCity": "Harefield, UK",
"canonicalUrl": "https://foursquare.com/user/113612142759476883204",

0 comments on commit c97399d

Please sign in to comment.