private function authenticate()
  {

    $dsDrupalAPIConfig = $this->mbConfig->getProperty('ds_drupal_api_config');

    if (!empty($dsDrupalAPIConfig['username']) && !empty($dsDrupalAPIConfig['password'])) {
      $post = [
        'username' => $dsDrupalAPIConfig['username'],
        'password' => $dsDrupalAPIConfig['password'],
      ];
    } else {
      trigger_error("MB_Toolbox->authenticate() : username and/or password not defined.", E_USER_ERROR);
      exit(0);
    }

    // https://www.dosomething.org/api/v1/auth/login
    $curlUrl  = $this->buildcURL($dsDrupalAPIConfig);
    $curlUrl .= self::DRUPAL_API . '/auth/login';
    $auth = $this->curlPOST($curlUrl, $post);

    if ($auth[1] == 200) {
      $auth = $auth[0];
    } else {
      echo 'ERROR - Failed to get auth creds: ' . $curlUrl . ' with POST: ' . print_r($post, true), PHP_EOL;
      $auth = false;
    }

    $this->auth = $auth;

    $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: authenticate', 1);
  }
private function authenticate()
  {

    $dsDrupalAPIConfig = $this->mbConfig->getProperty('ds_drupal_api_config');

    if (!empty($dsDrupalAPIConfig['username']) && !empty($dsDrupalAPIConfig['password'])) {
      $post = [
        'username' => $dsDrupalAPIConfig['username'],
        'password' => $dsDrupalAPIConfig['password'],
      ];
    } else {
      trigger_error("MB_Toolbox->authenticate() : username and/or password not defined.", E_USER_ERROR);
      exit(0);
    }

    // https://www.dosomething.org/api/v1/auth/login
    $curlUrl  = $this->buildcURL($dsDrupalAPIConfig);
    $curlUrl .= self::DRUPAL_API . '/auth/login';
    $auth = $this->curlPOST($curlUrl, $post);

    if ($auth[1] == 200) {
      $auth = $auth[0];
    } else {
      echo 'ERROR - Failed to get auth creds: ' . $curlUrl . ' with POST: ' . print_r($post, true), PHP_EOL;
      $auth = false;
    }

    $this->auth = $auth;

    $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: authenticate', 1);
  }
private function authenticate ( ) { $ dsDrupalAPIConfig = $ this -> mbConfig -> getProperty ( 'ds_drupal_api_config' ) ; if ( ! empty ( $ dsDrupalAPIConfig [ 'username' ] ) && ! empty ( $ dsDrupalAPIConfig [ 'password' ] ) ) { $ post = [ 'username' => $ dsDrupalAPIConfig [ 'username' ] , 'password' => $ dsDrupalAPIConfig [ 'password' ] , ] ; } else { trigger_error ( "MB_Toolbox->authenticate() : username and/or password not defined." , E_USER_ERROR ) ; exit ( 0 ) ; } // https://www.dosomething.org/api/v1/auth/login $ curlUrl = $ this -> buildcURL ( $ dsDrupalAPIConfig ) ; $ curlUrl .= self :: DRUPAL_API . '/auth/login' ; $ auth = $ this -> curlPOST ( $ curlUrl , $ post ) ; if ( $ auth [ 1 ] == 200 ) { $ auth = $ auth [ 0 ] ; } else { echo 'ERROR - Failed to get auth creds: ' . $ curlUrl . ' with POST: ' . print_r ( $ post , true ) , PHP_EOL ; $ auth = false ; } $ this -> auth = $ auth ; $ this -> statHat -> ezCount ( 'MB_Toolbox: MB_Toolbox_cURL: authenticate' , 1 ) ; }
Authenticate for Drupal API access
Authenticate for Drupal API access