$username = $user.'@'.$host;
$url = 'https://'.$host.'/api/user/'.$user.'/feed';
- $success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
+ else
+ $success = false;
if($success) {
$url = 'https://'.$hostname.'/api/user/'.$username.'/feed';
- $success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
+ else
+ $success = false;
if($success)
logger('pumpio_action '.$username.' '.$action.': success '.$uri);
$username = $user.'@'.$host;
- $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
+ else
+ $success = false;
if (!$success) {
logger('pumpio: error fetching posts for user '.$uid." ".$username." ".print_r($user, true));
if ($last_id != "")
$url .= '?since='.urlencode($last_id);
- $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
+ else
+ $success = false;
if ($user->items) {
$posts = array_reverse($user->items);
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
- $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
+ else
+ $success = false;
if ($users->totalItems > count($users->items)) {
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
- $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
+ else
+ $success = false;
}
foreach ($users->items AS $user)
$client->client_id = $consumer_key;
$client->client_secret = $consumer_secret;
- $success = $client->CallAPI($z['url'], 'POST', $z['post'], array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
+ if (pumpio_reachable($z['url']))
+ $success = $client->CallAPI($z['url'], 'POST', $z['post'], array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
+ else
+ $success = false;
if($success) {
$post_id = $user->object->id;
logger("pumpio_fetchallcomments: fetching comment for user ".$uid." url ".$url);
- $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $item);
+ if (pumpio_reachable($url))
+ $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $item);
+ else
+ $success = false;
if (!$success)
return;
}
}
+
+function pumpio_reachable($url) {
+ $data = z_fetch_url($url, false, $redirects, array('timeout'=>10));
+
+ return($data['success']);
+}
+
/*
To-Do:
- edit own notes