You are here

function wordstream_include_api_class in WordStream Keyword Tools 7

Same name and namespace in other branches
  1. 6 wordstream.module \wordstream_include_api_class()

@todo Please document this function.

See also

http://drupal.org/node/1354

2 calls to wordstream_include_api_class()
wordstream_admin_settings in ./wordstream.admin.inc
Displays the form for the standard settings tab.
wordstream_get_keyword_data in ./wordstream.module
Generates keyword search volume data from WordStream

File

./wordstream.module, line 88

Code

function wordstream_include_api_class($username = NULL, $password = NULL) {
  include_once drupal_get_path('module', 'wordstream') . '/class.wordstream.inc';
  $un = $username ? $username : variable_get('wordstream_username', '');
  $pw = $password ? $password : variable_get('wordstream_password', '');
  if ($un && $pw) {
    $wordstream = new WordStream($un, $pw);
    if (!$_SESSION['wordstream']['sid']) {
      $ret = $wordstream
        ->login();
      list($un, $sid) = explode(':', $ret);
      $_SESSION['wordstream']['sid'] = $sid;
    }
  }
  else {

    /*
        drupal_set_message(
     t('The username and password is not set for the WordStream API. !set',
       array(
         '!set' => l(t('Set credentials.'), 'admin/config/wordstream')
       )
    ), 'error');
    */
    return FALSE;
  }
  return $wordstream;
}