/**
  * Create a new instance of the adapter by wrapping an existing object.
  * @param HTTP_OAuth_Consumer $object
  * @return Imgur_HTTPAdapter_OAuth_HTTPOAuthConsumer
  **/
 public static function createByWrapping($object)
 {
     $foo = new Imgur_HTTPAdapter_OAuth_HTTPOAuthConsumer();
     $consumer_request = clone $object->getOAuthConsumerRequest();
     // Oh, what a mess.
     $consumer_request->setSecrets($object->getSecrets());
     $consumer_request->setParameters(array('oauth_consumer_key' => $object->getKey(), 'oauth_signature_method' => $object->getSignatureMethod(), 'oauth_token' => $object->getToken()));
     $foo->wrap($consumer_request);
     return $foo;
 }

if (empty($data['oauth_token']) || empty($data['oauth_token_secret'])) {
    throw new HTTP_OAuth_Consumer_Exception_InvalidResponse(
       'Failed getting token and token secret from response', $response
    );
}

print_r($data);

$consumer->setToken($data['oauth_token']);
$consumer->setTokenSecret($data['oauth_token_secret']);


// 5. Save credentials to config file
$handle = @fopen("visualplatform.config.php", "w");
$_conf = array(
                'domain'       => $data['domain'],
                'user_id'      => $data['user_id'],
                'key'          => $consumer->getKey(),
                'secret'       => $consumer->getSecret(),
                'token'        => $consumer->getToken(),
                'token_secret' => $consumer->getTokenSecret()
        );
fwrite($handle, '<? $visualplatform_config = unserialize(\'' . serialize($_conf) . '\'); ?>');
fclose($handle);



?>