Web::engine PHP Method

engine() public method

Specify the HTTP request engine to use; If not available, fall back to an applicable substitute
public engine ( $arg = 'curl' ) : string
$arg string
return string
    function engine($arg = 'curl')
    {
        $arg = strtolower($arg);
        $flags = ['curl' => extension_loaded('curl'), 'stream' => ini_get('allow_url_fopen'), 'socket' => function_exists('fsockopen')];
        if ($flags[$arg]) {
            return $this->wrapper = $arg;
        }
        foreach ($flags as $key => $val) {
            if ($val) {
                return $this->wrapper = $key;
            }
        }
        user_error(self::E_Request, E_USER_ERROR);
    }

Usage Example

Example #1
0
 public function __construct($appKey, $appSecret)
 {
     $this->appKey = $appKey;
     $this->appSecret = $appSecret;
     $this->f3 = \Base::instance();
     $this->web = \Web::instance();
     $this->web->engine('curl');
     $this->authToken = $this->f3->get('SESSION.dropbox.authToken');
     $this->authSecret = $this->f3->get('SESSION.dropbox.authSecret');
     $this->reqParams = array('oauth_consumer_key' => $this->appKey, 'oauth_version' => '1.0', 'oauth_signature' => $this->appSecret . '&', 'oauth_signature_method' => 'PLAINTEXT', 'oauth_timestamp' => strftime("%a, %d %b %Y %H:%M:%S %Z", time()));
     $this->authParams = $this->reqParams + array('oauth_token' => $this->authToken);
     $this->authParams['oauth_signature'] .= $this->authSecret;
 }