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 helper needs_api_tokens() #44

Open
sebsel opened this issue Jun 24, 2017 · 0 comments
Open

Add helper needs_api_tokens() #44

sebsel opened this issue Jun 24, 2017 · 0 comments

Comments

@sebsel
Copy link
Contributor

sebsel commented Jun 24, 2017

Might it be a good idea to add this helper function to helpers.php, now that there are 3 silo's that need API keys?

function needs_api_tokens($url) {
  if(Formats\GitHub::matches_host($url)) return 'github';
  if(Formats\Twitter::matches_host($url)) return 'twitter';
  if(Formats\Facebook::matches_host($url)) return 'facebook';
  return false;
}

Instead of these strings, we can also return an array of the credentials we expect.

function needs_api_tokens($url) {
  if(Formats\GitHub::matches_host($url)) return ['github_access_token'];
  if(Formats\Twitter::matches_host($url)) return ['twitter_api_key','twitter_api_secret','twitter_access_token','twitter_access_token_secret'];
  if(Formats\Facebook::matches_host($url)) return ['facebook_app_id','facebook_app_secret'];
  return [];
}
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