Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add errors processing #22

Open
max-kk opened this issue Oct 25, 2016 · 0 comments
Open

Add errors processing #22

max-kk opened this issue Oct 25, 2016 · 0 comments

Comments

@max-kk
Copy link

max-kk commented Oct 25, 2016

There is an example from PHP when your IP had been blocked (hope temporary), due too many requests. (IP Ban has beed gone in about 10 mintes)

object(stdClass)#3 (2) {
  ["status"]=>
  string(4) "fail"
  ["message"]=>
  string(49) "Sorry, too many requests. Please try again later."
}

I think there was a sense add something like

if ( isset($media->status) && "fail" == $media->status ) {
     //error_log( "Your IP had been blocked by Instagram due too many requests!" );
     return false;
}

Also I think have sense move code to retreieving data into separated function, like

function _get_remote_data ( $url ) {
    $media = json_decode(file_get_contents($url), false);
    // Process errors
   // Return data
}

This allows

  • Extend main class to override this function and use for example WP funcion for getting results (wp_remote_get)
  • Avoid code dublicates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant