Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LocalStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ protected function assign_data_value($type, $value) {
}

function setup_temporary_dir() {
$path="/tmp";
$prefix="offlickr2.";
// FIXME: Not atomic
$tempname = tempnam($path,$prefix);
if (!$tempname) {
Expand Down
5 changes: 5 additions & 0 deletions Offlickr2.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,13 @@ private function get_photo_list() {
if (count($photos['photo']) == 0) {
break;
}
if ($page > $photos['pages']) {
printf ("DEBUG: past the end of pages? $page > %s\n", $photos['pages']);
break;
}
foreach ($photos['photo'] as $photo) {
array_push($this->photo_list, $photo['id']);
printf ("DEBUG: %s %d\n", $photo['id'], $page);
}
$retrieved = count($this->photo_list);
$this->dialog->info(2, "Total so far: " . $retrieved . " photo(s)");
Expand Down
21 changes: 16 additions & 5 deletions oPhpFlickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function authorize_console() {
return $accessToken;
}

function request ($command, $args = array()) {
function request ($command, $args = array(), $already_tried=0) {
// NOTE: cache not implemented

$args = array_merge(
Expand All @@ -40,15 +40,26 @@ function request ($command, $args = array()) {
$request = new OAuthRequest(Verb::POST, $args['url']);
foreach ($args as $key => $value) {
$request->addBodyParameter($key, $value);
print("*** request[" . $key . "]=" . $value . "\n");
}
$this->oauth_service->signRequest($this->token, $request);
$response_object = $request->send();
$response = $response_object->getBody();

$this->parsed_response = json_decode($response, TRUE);
$this->parsed_response = json_decode($response, TRUE);
if ($this->parsed_response['stat'] == 'fail') {
if ($this->die_on_error) die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
else {
if ($this->die_on_error) {
if ($already_tried > 3) {
die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
} else {
print("warning: (retry {$already_tried}<=3) The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}\n");
$sleep = 1 * 10**$already_tried;
print("Sleeping {$sleep} seconds\n");
sleep($sleep);
$already_tried++;
$this->request($command, $args, $already_tried);
}
} else {
$this->error_code = $this->parsed_response['code'];
$this->error_msg = $this->parsed_response['message'];
$this->parsed_response = false;
Expand All @@ -62,4 +73,4 @@ function request ($command, $args = array()) {

}

?>
?>