{ return in_array(strtolower($needle), array_map('strtolower', $haystack)); } /** Please send me: array( 'uri'=> '', 'method'=>''[, 'curloptions'=> array( ... ) ]) I will throw an Exception if something goes wrong so no need to validate But you can decide whether you wnat me to do it or not */ public static function sendRequest($arrayParms, $throwEx = true) { Utils::arrayKeyExists(array('url', 'method'), $arrayParms); $client = new \Zend\Http\Client($arrayParms['url']); $client->setMethod($arrayParms['method']); switch ($arrayParms['method']) { case POST: Utils::arrayKeyExists('payload', $arrayParms); $client->setParameterPost($arrayParms['payload']); break; case GET: Utils::arrayKeyExists('payload', $arrayParms); $client->setParameterGet($arrayParms['payload']); break; } $adapter = new \Zend\Http\Client\Adapter\Curl(); $curloptions = array(CURLOPT_POST => 1, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE); if (array_key_exists('curloptions', $arrayParms)) { $curloptions = array_merge($curloptions, $arrayParms['curloptions']); } $adapter->setOptions(array('curloptions' => $curloptions)); $client->setAdapter($adapter); $response = $client->send(); if ($response->isSuccess()) {
/** * * @return \ZendGData\HttpClient */ private function getGoogleClient() { $adapter = new \Zend\Http\Client\Adapter\Curl(); $adapter->setOptions(array('curloptions' => array(CURLOPT_SSL_VERIFYPEER => false))); $httpClient = new \ZendGData\HttpClient(); $httpClient->setAdapter($adapter); $client = \ZendGData\ClientLogin::getHttpClient(self::GOOGLE_USER_ID, self::GOOGLE_PASSWORD, \ZendGData\Photos::AUTH_SERVICE_NAME, $httpClient); return $client; }
protected function getPaypalRequest() { $config = $this->getServiceLocator()->get('config'); $paypalConfig = new \SpeckPaypal\Element\Config($config['speck-paypal-api']); $adapter = new \Zend\Http\Client\Adapter\Curl(); $adapter->setOptions(array('curloptions' => array(CURLOPT_SSL_VERIFYPEER => false))); $client = new \Zend\Http\Client(); $client->setMethod('POST'); $client->setAdapter($adapter); $paypalRequest = new \SpeckPaypal\Service\Request(); $paypalRequest->setClient($client); $paypalRequest->setConfig($paypalConfig); return $paypalRequest; }