本文整理汇总了PHP中Logger::logInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::logInfo方法的具体用法?PHP Logger::logInfo怎么用?PHP Logger::logInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::logInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processPostURLs
/**
* For a given post, extract URLs and store them, including image_src if that's from a known source like Twitpic,
* Twitgoo, Yfrog, Instagr.am.
* @param str $post_text
* @param int $post_id
* @param str $network
* @param Logger $logger
* @param arr $urls Array of URLs, optionally set, defaults to null
*/
public static function processPostURLs($post_text, $post_id, $network, $logger, $urls = null)
{
if (!$urls) {
$urls = Post::extractURLs($post_text);
}
if ($urls) {
$link_dao = DAOFactory::getDAO('LinkDAO');
$post_dao = DAOFactory::getDAO('PostDAO');
$post = $post_dao->getPost($post_id, $network);
if (isset($post->id)) {
foreach ($urls as $url) {
$logger->logInfo("Processing URL {$url}", __METHOD__ . ',' . __LINE__);
$image_src = self::getImageSource($url);
//if we have an image_src, the URL is a known image source not in need of expansion
$expanded_url = $image_src !== '' ? $url : '';
$link_array = array('url' => $url, 'expanded_url' => $expanded_url, "image_src" => $image_src, 'post_key' => $post->id);
$link = new Link($link_array);
try {
$link_dao->insert($link);
$logger->logSuccess("Inserted " . $url . " " . ($image_src == '' ? '' : "(thumbnail " . $image_src . ") ") . "into links table", __METHOD__ . ',' . __LINE__);
} catch (DuplicateLinkException $e) {
$logger->logInfo($url . " " . ($image_src == '' ? '' : "(thumbnail " . $image_src . ") ") . " already exists in links table", __METHOD__ . ',' . __LINE__);
} catch (DataExceedsColumnWidthException $e) {
$logger->logInfo($url . " " . ($image_src == '' ? '' : "(thumbnail " . $image_src . ") ") . " data exceeds table column width", __METHOD__ . ',' . __LINE__);
}
}
}
}
}
示例2: updateFriendsProfiles
/**
* Update profiles of users who are friends of the instance user, and haven't been checked in 1 day.
* @return void
*/
public function updateFriendsProfiles()
{
if (!isset($this->user)) {
$this->fetchInstanceUserInfo();
}
if (isset($this->user)) {
//Get stalest friends
$follow_dao = DAOFactory::getDAO('FollowDAO');
$stalest_friends = $follow_dao->getStalestFriends($this->user->user_id, 'twitter', $number_days_old = 1, $limit = 25);
$status_message = count($stalest_friends) . ' friends haven\'t been updated recently.';
$this->logger->logInfo($status_message, __METHOD__ . ',' . __LINE__);
while (isset($stalest_friends) && count($stalest_friends) > 0) {
try {
foreach ($stalest_friends as $user) {
$this->fetchAndAddUser($user->user_id, "Friends stale update");
}
$stalest_friends = $follow_dao->getStalestFriends($this->user->user_id, 'twitter', $number_days_old = 1, $limit = 25);
$status_message = count($stalest_friends) . ' friends haven\'t been updated recently.';
$this->logger->logInfo($status_message, __METHOD__ . ',' . __LINE__);
} catch (APICallLimitExceededException $e) {
$this->logger->logInfo($e->getMessage(), __METHOD__ . ',' . __LINE__);
break;
}
}
}
}
示例3: updateStaleFriendsProfiles
/**
* Update profiles of users who are friends of the instance user, and haven't been checked in 2 days.
* @return void
*/
public function updateStaleFriendsProfiles()
{
if (!isset($this->user)) {
//Force-refresh instance user in data store
$this->user = self::fetchUser($this->instance->network_user_id, 'Owner info', $this->instance->network_username, null, null, true);
}
if (isset($this->user)) {
//Get stalest friends
$follow_dao = DAOFactory::getDAO('FollowDAO');
$stalest_friends = $follow_dao->getStalestFriends($this->user->user_id, 'instagram', $number_days_old = 2, $limit = 25);
$status_message = count($stalest_friends) . ' friends haven\'t been updated recently.';
$this->logger->logInfo($status_message, __METHOD__ . ',' . __LINE__);
while (isset($stalest_friends) && count($stalest_friends) > 0) {
try {
foreach ($stalest_friends as $user) {
$this->fetchUser($user->user_id, "Friends stale update", $user->username, $user->full_name, $user->avatar, true);
}
$stalest_friends = $follow_dao->getStalestFriends($this->user->user_id, 'instagram', $number_days_old = 2, $limit = 25);
$status_message = count($stalest_friends) . ' friends haven\'t been updated recently.';
$this->logger->logInfo($status_message, __METHOD__ . ',' . __LINE__);
} catch (APICallLimitExceededException $e) {
$this->logger->logInfo($e->getMessage(), __METHOD__ . ',' . __LINE__);
break;
}
}
}
}
示例4: getFavorites
/**
* This helper method returns the parsed favorites from a given favorites page.
* @param int $since_id
* @return array ($tweets, $http_status, $payload)
*/
private function getFavorites($since_id)
{
$endpoint = $this->api->endpoints['favorites'];
$args = array();
$args["screen_name"] = $this->user->username;
$args["include_entities"] = "false";
$args["count"] = 100;
if ($since_id != "") {
$args["since_id"] = $since_id;
}
try {
list($http_status, $payload) = $this->api->apiRequest($endpoint, $args);
if ($http_status == 200) {
// Parse the JSON file
$tweets = $this->api->parseJSONTweets($payload);
if (!(isset($tweets) && sizeof($tweets) == 0) && $tweets == null) {
// arghh, empty array evals to null
$this->logger->logInfo("in getFavorites; could not extract any tweets from response", __METHOD__ . ',' . __LINE__);
throw new Exception("could not extract any tweets from response");
}
}
} catch (APICallLimitExceededException $e) {
$this->logger->logInfo($e->getMessage(), __METHOD__ . ',' . __LINE__);
}
return array($tweets, $http_status, $payload);
}
示例5: storePostsAndAuthors
private function storePostsAndAuthors($posts, $posts_source)
{
$total_added_posts = 0;
$added_posts = 0;
$post_dao = DAOFactory::getDAO('PostDAO');
foreach ($posts as $post) {
if (isset($post['author_user_id'])) {
$user_object = $this->fetchUserInfo($post['author_user_id'], 'facebook', $posts_source);
if (isset($user_object)) {
$post["author_username"] = $user_object->full_name;
$post["author_fullname"] = $user_object->full_name;
$post["author_avatar"] = $user_object->avatar;
$post["location"] = $user_object->location;
}
}
$added_posts = $post_dao->addPost($post);
if ($added_posts == 0 && isset($post['favlike_count_cache'])) {
//post already exists in storage, so update its like count only
$post_dao->updateFavLikeCount($post['post_id'], $post['network'], $post['favlike_count_cache']);
$this->logger->logInfo("Updated Like count for post ID " . $post["post_id"] . " to " . $post['favlike_count_cache'], __METHOD__ . ',' . __LINE__);
}
if ($added_posts > 0) {
$this->logger->logInfo("Added post ID " . $post["post_id"] . " on " . $post["network"] . " for " . $post["author_username"] . ":" . $post["post_text"], __METHOD__ . ',' . __LINE__);
}
$total_added_posts = $total_added_posts + $added_posts;
$added_posts = 0;
}
return $added_posts;
}
示例6: initializeInstanceUser
/**
* Check the validity of G+'s OAuth token by requestig the instance user's details.
* Fetch details from Google+ API for the current instance user and insert into the datastore.
* @param str $client_id
* @param str $client_secret
* @param str $access_token
* @param str $refresh_token
* @param str $owner_id
* @return User
*/
public function initializeInstanceUser($client_id, $client_secret, $access_token, $refresh_token, $owner_id)
{
$network = 'google+';
$user_dao = DAOFactory::getDAO('UserDAO');
$user_object = null;
// Get owner user details and save them to DB
$fields = array('fields' => 'displayName,id,image,tagline');
$user_details = $this->api_accessor->apiRequest('people/me', $this->access_token, $fields);
if (isset($user_details->error->code) && $user_details->error->code == '401') {
//Token has expired, fetch and save a new one
$tokens = self::getOAuthTokens($client_id, $client_secret, $refresh_token, 'refresh_token');
$owner_instance_dao = DAOFactory::getDAO('OwnerInstanceDAO');
$owner_instance_dao->updateTokens($owner_id, $this->instance->id, $access_token, $refresh_token);
$this->access_token = $tokens->access_token;
//try again
$user_details = $this->api_accessor->apiRequest('people/me', $this->access_token, $fields);
}
$user_details->network = $network;
$user = $this->parseUserDetails($user_details);
if (isset($user)) {
$user_object = new User($user, 'Owner initialization');
$user_dao->updateUser($user_object);
}
if (isset($user_object)) {
$this->logger->logSuccess("Successfully fetched " . $user_object->username . " " . $user_object->network . "'s details from Google+", __METHOD__ . ',' . __LINE__);
} else {
$this->logger->logInfo("Error fetching " . $user_id . " " . $network . "'s details from the Google+ API, " . "response was " . Utils::varDumpToString($user_details), __METHOD__ . ',' . __LINE__);
}
return $user_object;
}
示例7: fetchUserFromYouTube
/**
* For fetching details about a user who does not have a Gooogle Plus ID
* If user doesn't exist in the datastore, fetch details from YouTube API and insert into the datastore.
* If $reload_from_youtube is true, update existing user details in store with data from YouTube API.
* @param int $user_id YouTube user ID
* @param str $found_in Where the user was found
* @param bool $reload_from_youtube Defaults to false; if true will query YouTube API and update existing user
* @return User
*/
public function fetchUserFromYouTube($user_id, $found_in, $force_reload_from_youtube = false)
{
$network = 'youtube';
$user_dao = DAOFactory::getDAO('UserDAO');
$user_object = null;
if ($force_reload_from_youtube || !$user_dao->isUserInDB($user_id, $network)) {
// Get owner user details and save them to DB
$fields = array('alt' => 'json');
if (isset($this->developer_key)) {
$fields['key'] = $this->developer_key;
}
$user_details = $this->youtube_api_v2_accessor->apiRequest('users/' . $user_id_string[sizeof($user_id_string) - 1], $fields);
$user = $this->parseYouTubeUserDetails($user_details->entry);
if (isset($user)) {
$user_object = new User($user, $found_in);
$user_dao->updateUser($user_object);
}
if (isset($user_object)) {
$this->logger->logSuccess("Successfully fetched " . $user_id . " " . $network . "'s details from YouTube", __METHOD__ . ',' . __LINE__);
} else {
$this->logger->logInfo("Error fetching " . $user_id . " " . $network . "'s details from the YouTube API, " . "response was " . Utils::varDumpToString($user_details), __METHOD__ . ',' . __LINE__);
}
}
return $user_object;
}
示例8: processTweetURLs
/**
* If link is an image (Twitpic/Twitgoo/Yfrog/Flickr for now), insert direct path to thumb as expanded url.
* @TODO Move image thumbnail processng to Expand URLs plugin.
* @param Logger $logger
* @param str $tweet
* @param Array $urls
*/
public static function processTweetURLs($logger, $tweet, $urls = null)
{
$link_dao = DAOFactory::getDAO('LinkDAO');
if (!$urls) {
$urls = Post::extractURLs($tweet['post_text']);
}
foreach ($urls as $u) {
$logger->logInfo("processing url: {$u}", __METHOD__ . ',' . __LINE__);
$is_image = 0;
$title = '';
$eurl = '';
if (substr($u, 0, strlen('http://twitpic.com/')) == 'http://twitpic.com/') {
$eurl = 'http://twitpic.com/show/thumb/' . substr($u, strlen('http://twitpic.com/'));
$is_image = 1;
} elseif (substr($u, 0, strlen('http://yfrog.com/')) == 'http://yfrog.com/') {
$eurl = $u . '.th.jpg';
$is_image = 1;
} elseif (substr($u, 0, strlen('http://twitgoo.com/')) == 'http://twitgoo.com/') {
$eurl = 'http://twitgoo.com/show/thumb/' . substr($u, strlen('http://twitgoo.com/'));
$is_image = 1;
} elseif (substr($u, 0, strlen('http://picplz.com/')) == 'http://picplz.com/') {
$eurl = $u . '/thumb/';
$is_image = 1;
} elseif (substr($u, 0, strlen('http://flic.kr/')) == 'http://flic.kr/') {
$is_image = 1;
} elseif (substr($u, 0, strlen('http://instagr.am/')) == 'http://instagr.am/') {
$is_image = 1;
}
if ($link_dao->insert($u, $eurl, $title, $tweet['post_id'], 'twitter', $is_image)) {
$logger->logSuccess("Inserted " . $u . " (" . $eurl . ", " . $is_image . "), into links table", __METHOD__ . ',' . __LINE__);
} else {
$logger->logError("Did NOT insert " . $u . " (" . $eurl . ") into links table", __METHOD__ . ',' . __LINE__);
}
}
}
示例9: apiRequest
/**
* Make an API request.
* @param str $type String representing the endpoint, 'user', 'followers', 'media', 'relationship'
* @param arr $params API call params
* @return Object
*/
public function apiRequest($type, $params = array())
{
if ($this->total_api_calls >= $this->max_api_calls) {
$this->logger->logInfo("Throw APICallLimitExceededException", __METHOD__ . ',' . __LINE__);
throw new APICallLimitExceededException();
} else {
$this->total_api_calls++;
$this->logger->logInfo("Made " . $this->total_api_calls . " API calls", __METHOD__ . ',' . __LINE__);
}
try {
if ($type == 'user') {
return $this->instagram->getUser($params['user_id']);
} else {
if ($type == 'followers') {
return $this->current_user->getFollowers($params);
} else {
if ($type == 'friends') {
return $this->current_user->getFollows($params);
} else {
if ($type == 'media') {
return $this->current_user->getMedia($params);
} else {
if ($type == 'relationship') {
return $this->current_user->getRelationship($params['user_id']);
} else {
if ($type == 'likes') {
return $this->current_user->getLikedMedia($params);
}
}
}
}
}
}
} catch (Instagram\Core\ApiException $e) {
if ($e->getMessage() == 'you cannot view this resource') {
$this->logger->logInfo("Throw APICallPermissionDeniedException: " . $e->getMessage(), __METHOD__ . ',' . __LINE__);
throw new APICallPermissionDeniedException($e->getMessage());
} elseif (strpos($e->getMessage(), 'exceeded the maximum number of requests per hour') !== false) {
$this->logger->logInfo("Throw APICallLimitExceededException: " . $e->getMessage(), __METHOD__ . ',' . __LINE__);
throw new APICallLimitExceededException($e->getMessage());
} else {
$this->logger->logInfo("Throw APIErrorException: " . $e->getMessage(), __METHOD__ . ',' . __LINE__);
throw new APIErrorException($e->getMessage());
}
}
}
示例10: fetchInstanceUserPosts
/**
* Capture the current instance users's posts and store them in the database.
* @return null
*/
public function fetchInstanceUserPosts()
{
//For now only capture the most recent 20 posts
//@TODO Page back through all the archives
$fields = array('alt' => 'json', 'maxResults' => 20, 'pp' => 1);
$user_posts = $this->api_accessor->apiRequest('people/' . $this->instance->network_user_id . '/activities/public', $this->access_token, $fields);
if (isset($user_posts->items)) {
$post_dao = DAOFactory::getDAO('PostDAO');
$link_dao = DAOFactory::getDAO('LinkDAO');
foreach ($user_posts->items as $item) {
$should_capture_post = false;
//For now we're only capturing posts and shares
//@TODO Capture all types of posts
if ($item->verb == "post") {
$post['post_text'] = $item->object->content;
$should_capture_post = true;
} elseif ($item->verb == "share") {
$post['post_text'] = isset($item->annotation) ? $item->annotation : '';
$should_capture_post = true;
}
if ($should_capture_post) {
$post['post_id'] = $item->id;
$post['author_username'] = $item->actor->displayName;
$post['author_fullname'] = $item->actor->displayName;
$post['author_avatar'] = $item->actor->image->url;
$post['author_user_id'] = $item->actor->id;
$post['pub_date'] = $item->published;
$post['source'] = '';
$post['is_protected'] = false;
$post['network'] = 'google+';
$post['reply_count_cache'] = $item->object->replies->totalItems;
$post['favlike_count_cache'] = $item->object->plusoners->totalItems;
$post['retweet_count_cache'] = $item->object->resharers->totalItems;
$inserted_post_key = $post_dao->addPost($post);
//If no post was added, at least update reply/fave/reshare counts and post text
if ($inserted_post_key === false) {
$post_dao->updateFavLikeCount($post['post_id'], 'google+', $post['favlike_count_cache']);
$post_dao->updateReplyCount($post['post_id'], 'google+', $post['reply_count_cache']);
$post_dao->updateRetweetCount($post['post_id'], 'google+', $post['retweet_count_cache']);
$post_dao->updatePostText($post['post_id'], 'google+', $post['post_text']);
}
if (isset($item->object->attachments) && isset($item->object->attachments[0]->url)) {
$link_url = $item->object->attachments[0]->url;
$link = new Link(array("url" => $link_url, "expanded_url" => '', "image_src" => isset($item->object->attachments[0]->image->url) ? $item->object->attachments[0]->image->url : '', "caption" => '', "description" => isset($item->object->attachments[0]->content) ? $item->object->attachments[0]->content : '', "title" => isset($item->object->attachments[0]->displayName) ? $item->object->attachments[0]->displayName : '', "post_key" => $inserted_post_key));
try {
$added_links = $link_dao->insert($link);
} catch (DuplicateLinkException $e) {
$this->logger->logInfo($link->url . " already exists in links table", __METHOD__ . ',' . __LINE__);
} catch (DataExceedsColumnWidthException $e) {
$this->logger->logInfo($link->url . " data exceeds table column width", __METHOD__ . ',' . __LINE__);
}
}
}
$post = null;
$link = null;
}
}
}
示例11: storeFriends
/**
* Retrives all of a users friends from the Instagram API and stores them in the database
* @return null
*/
private function storeFriends()
{
if ($this->instance->network != 'instagram') {
return;
}
//Retrieve friends via the Instagram API
$user_id = $this->instance->network_user_id;
$access_token = $this->access_token;
$network = $user_id == $this->instance->network_user_id ? $this->instance->network : 'instagram';
try {
$friends = InstagramAPIAccessor::apiRequest('friends', $user_id, $access_token);
} catch (Instagram\Core\ApiException $e) {
$this->logger->logInfo(get_class($e) . " Error fetching friends from Instagram API, error was " . $e->getMessage(), __METHOD__ . ',' . __LINE__);
return;
}
if (isset($friends)) {
//store relationships in follows table
$follows_dao = DAOFactory::getDAO('FollowDAO');
$count_dao = DAOFactory::getDAO('CountHistoryDAO');
$user_dao = DAOFactory::getDAO('UserDAO');
foreach ($friends as $friend) {
$follower_id = null;
try {
$follower_id = $friend->getId();
} catch (Instagram\Core\ApiException $e) {
$this->logger->logInfo(get_class($e) . " Error fetching " . Utils::varDumpToString($friend) . "'s details from Instagram API, error was " . $e->getMessage(), __METHOD__ . ',' . __LINE__);
}
if (isset($follower_id)) {
if ($follows_dao->followExists($user_id, $follower_id, $network)) {
// follow relationship already exists
$follows_dao->update($user_id, $follower_id, $network);
} else {
// follow relationship does not exist yet
$follows_dao->insert($user_id, $follower_id, $network);
}
$follower_details = $friend;
if (isset($follower_details)) {
$follower_details->network = $network;
}
$follower = $this->parseUserDetails($follower_details);
$follower_object = new User($follower);
if (isset($follower_object)) {
$user_dao->updateUser($follower_object);
}
}
}
//totals in follower_count table
$count_dao->insert($user_id, $network, $friends->count(), null, 'followers');
} else {
throw new Instagram\Core\ApiAuthException('Error retrieving friends');
}
$this->logger->logInfo("Ending", __METHOD__ . ',' . __LINE__);
}
示例12: fetchPagePostsAndReplies
/**
* Fetch a save the posts and replies on a Facebook page.
* @param int $pid Page ID
*/
public function fetchPagePostsAndReplies($pid) {
$stream = FacebookGraphAPIAccessor::apiRequest('/'.$pid.'/posts', $this->access_token);
if (isset($stream->data) && is_array($stream->data) && sizeof($stream->data > 0)) {
$this->logger->logSuccess(sizeof($stream->data)." Facebook posts found for page ID $pid.",
__METHOD__.','.__LINE__);
$thinkup_data = $this->parseStream($stream, 'facebook page');
$posts = $thinkup_data["posts"];
$post_dao = DAOFactory::getDAO('PostDAO');
$added_posts = 0;
foreach ($posts as $post) {
if ($post['author_username']== "" && isset($post['author_user_id'])) {
$commenter_object = $this->fetchUserInfo($post['author_user_id'], 'facebook',
'Facebook page comments');
if (isset($commenter_object)) {
$post["author_username"] = $commenter_object->full_name;
$post["author_fullname"] = $commenter_object->full_name;
$post["author_avatar"] = $commenter_object->avatar;
}
}
$added_posts = $added_posts + $post_dao->addPost($post);
$this->logger->logInfo("Added post ID ".$post["post_id"]." on ".$post["network"].
" for ".$post["author_username"].":".$post["post_text"], __METHOD__.','.__LINE__);
}
$added_users = 0;
$users = $thinkup_data["users"];
if (count($users) > 0) {
foreach ($users as $user) {
$user["post_count"] = $post_dao->getTotalPostsByUser($user['user_id'], $user['network']);
$found_in = 'Facebook page stream';
$user_object = new User($user, $found_in);
$user_dao = DAOFactory::getDAO('UserDAO');
$user_dao->updateUser($user_object);
$added_users = $added_users + 1;
}
}
if ($added_posts > 0 || $added_users > 0) {
$this->logger->logUserSuccess($added_posts." post(s) added; ".$added_users." user(s) updated.",
__METHOD__.','.__LINE__);
} else {
$this->logger->logUserInfo("No new page posts found.", __METHOD__.','.__LINE__);
}
} else {
$this->logger->logInfo("No Facebook posts found for page ID $pid", __METHOD__.','.__LINE__);
}
}
示例13: testAddRmOldFavMaintSearch
public function testAddRmOldFavMaintSearch() {
$this->logger->logInfo("in testAddRmOldFavMaintSearch", __METHOD__.','.__LINE__);
//set plugin cfg values
$namespace = OptionDAO::PLUGIN_OPTIONS . '-1';
$builder2 = FixtureBuilder::build('options',
array('namespace' => $namespace, 'option_name'=>'favs_older_pages','option_value'=>1));
$builder3 = FixtureBuilder::build('options',
array('namespace' => $namespace, 'option_name'=>'favs_cleanup_pages','option_value'=>3));
$id = DAOFactory::getDAO('InstanceDAO');
self::setUpInstanceUserAmygdala();
$this->api->available_api_calls_for_crawler = 3;
$this->api->to->setDataPath('webapp/plugins/twitter/tests/testdata/favs_tests/favs_stage3/');
$tc = new TwitterCrawler($this->instance, $this->api);
$tc->fetchInstanceUserInfo();
$retval = $tc->cleanUpMissedFavsUnFavs();
$this->assertEqual($retval, true);
$this->assertEqual($this->instance->last_unfav_page_checked, 3);
// Save instance
if (isset($tc->user)) {
$id->save($this->instance, $tc->user->post_count, $this->logger);
}
$this->instance = $id->getByUsernameOnNetwork("amygdala", "twitter");
// check fav count
$this->assertEqual($this->instance->owner_favs_in_system, 40);
$this->logger->logInfo("in testAddRmOldFavMaintSearch, second traversal", __METHOD__.','.__LINE__ );
// now add an additional older fav , remove one, and traverse again
$this->api->available_api_calls_for_crawler = 3;
$this->instance->last_unfav_page_checked = 2;
$this->api->to->setDataPath('webapp/plugins/twitter/tests/testdata/favs_tests/favs_stage6/');
$tc = new TwitterCrawler($this->instance, $this->api);
$tc->fetchInstanceUserInfo();
$retval = $tc->cleanUpMissedFavsUnFavs();
$this->assertEqual($retval, true);
// Save instance
if (isset($tc->user)) {
$id->save($this->instance, $tc->user->post_count, $this->logger);
}
$this->instance = $id->getByUsernameOnNetwork("amygdala", "twitter");
// check fav count- should have removed 2 and added 21...
// update: due to issue with TwitterAPI, not currently removing un-favs from database
// $this->assertEqual($this->instance->owner_favs_in_system, 59);
$this->assertEqual($this->instance->owner_favs_in_system, 61);
$builder2 = null; $builder3 = null;
}
示例14: apiRequest
private function apiRequest($method, $encoded_params)
{
$api_call = $this->api_url . $method . implode('&', $encoded_params);
//Don't log this for privacy reasons; it will output the API key to the log
//$this->logger->logInfo("Bit.ly API call: $api_call", __METHOD__.','.__LINE__);
$resp = Utils::getURLContents($api_call);
//$this->logger->logInfo("Bit.ly API call response: ".$resp, __METHOD__.','.__LINE__);
if ($resp != false) {
$bit_link = json_decode($resp, true);
return $bit_link;
} else {
$this->logger->logInfo("ERROR: No response from Bit.ly API", __METHOD__ . ',' . __LINE__);
return array("expanded_url" => '', "title" => '', "clicks" => '', "error" => 'No response from Bit.ly API');
}
}
示例15: storeLinks
/**
* Store links.
* @param arr $links
* @return int Total links stored
*/
private function storeLinks($links)
{
$total_links_added = 0;
$link_dao = DAOFactory::getDAO('LinkDAO');
foreach ($links as $link) {
try {
$added_links = $link_dao->insert($link);
$total_links_added = $total_links_added + ($added_links ? 1 : 0);
} catch (DuplicateLinkException $e) {
$this->logger->logInfo($link->url . " already exists in links table", __METHOD__ . ',' . __LINE__);
} catch (DataExceedsColumnWidthException $e) {
$this->logger->logInfo($link->url . " data exceeds table column width", __METHOD__ . ',' . __LINE__);
}
}
return $total_links_added;
}