Perform the web request to the C@C API

@param string $where The endpont of the url
@param array $data Options for the web request
@param string $type GET or POST web request
@return bool
198659
private function _make_request($where, $data, $type = 'GET') {
		if ($type == 'GET') {
			try {
				$this->get(self::BASE_URL . self::API_VERSION . $where, $data);
				$this->_response = json_decode($this->response, true);
				if ($this->_response['status'] === 'ok') {
					if (array_key_exists('data', $this->_response)) {
						$this->_response = $this->_response['data'];
					}
					return true;
				} else {
					$this->_response = $this->_response;
					return false;
				}
			} catch (\Exception $e) {
				throw new \Exception('Something gone wrong', 0, $e);
			}
		} elseif ($type == 'POST') {
			try {
				$this->post(self::BASE_URL . self::API_VERSION . $where, $data);
				$this->_response = json_decode($this->response, true);
				if ($this->_response['status'] === 'ok') {
					if (array_key_exists('data', $this->_response)) {
						$this->_response = $this->_response['data'];
					}
					return true;
				} else {
					$this->_response = $this->_response;
					return false;
				}
			} catch (\Exception $e) {
				throw new \Exception('Something gone wrong', 0, $e);
			}
		} else {
			throw new \Exception('Invalid Request Type', 0);
		}

		$this->close();

		return false;
	}
786338
public function post($endpoint, array $data = [])
    {
        $body = json_encode($data);
        $request = $this->createRequest('POST', $endpoint, $body, ['Content-Type' => 'application/json']);
        return $this->sendRequest($request);
    }
31554
public function postRequest($uri, array $data = null)
    {
        return $this->getClient()->post($uri, [
            'json' => $this->createBody($data)
        ]);
    }
230531
public function call($method, array $data = null, $type = 'get')
    {
        $url = self::URL_PREFIX . '/' . $method . '?auth_token=' . $this->token;
        if ($data && $type == 'get') {
            $url .= '&' . implode('&', $data);
        }

        $options = [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true
        ];
        if ($data && $type == 'post') {
            $options[CURLOPT_POST] = true;
            $options[CURLOPT_POSTFIELDS] = $data;
        }
        $response = self::jsonValidate($this->executeCurl($options), $this->returnArray);

        return $response['data'];
    }
261801
public function request($method, $data = [])
    {
        $path = '_template/'.$this->getName();

        return $this->getClient()->request($path, $method, $data);
    }
243541
private function send($method, $uri, $data, $type = 'json')
    {
        // Make the Request to Watson.
        $response = $this->request($method, $uri, [$type => $data]);
        // Request Failed.
        if ($response->getStatusCode() != 200) {
            // Throw Watson Bridge Exception.
            $this->failedRequest($response);
        }

        // We return response.
        return $response;
    }
245633
public static function Facebook($type, $data)
    {
        switch ($type) {
            case 'link':
                $message = isset($data['message']) ? $data['message'] : '';
                $result = FacebookApi::sendLink($data['link'], $data['message']);
                break;
            case 'photo':
                $message = isset($data['message']) ? $data['message'] : '';
                $result = FacebookApi::sendPhoto($data['photo'], $message);
                break;
            case 'video':
                $description = isset($data['description']) ? $data['description'] : '';
                $result = FacebookApi::sendVideo($data['video'], $data['title'], $description);
                break;
        }

        return ($result > 0) ? true : false;
    }
45800
public function update($data, $where = [])
    {
        /*
         | Trigger Before Update events if
         | defined by user into model class
         |
         */
        $this->triggerEvent('beforeUpdate');

        if (!empty($where)) {
            $whereStr = $this->buildWherePlaceholderName($where);
        } else {
            list($where, $whereStr) = $this->buildWhereForUpdate();
        }

        $sql = $this->getUpdateQuery($data, strtoupper(__FUNCTION__)).$whereStr;

        try {
            $stmt = $this->resolveConnection()->prepare($sql);

            //Bind all values to query statement
            foreach ($data as $key => $val) {
                $stmt->bindValue(":$key", $val);
            }

            foreach ($where as $key => $value) {
                $stmt->bindValue(":$key", $value);
            }

            static::$queries[] = $stmt->queryString;
            $affectedRow = $stmt->execute();

            /*
             | Trigger after update events if defined
             | into model class
             |
             */
            $this->triggerEvent('afterUpdate');

            return $affectedRow;
        } catch (\PDOException  $exception) {
            throw new \Exception($exception->getMessage());
        }
    }
56378
protected function _customRequest($url, $data, $type)
    {
        $response = $this->curl->init($this->url ?? $url)
                        ->option('returntransfer', true)
                        ->option('customrequest', strtoupper($type))
                        ->option('ssl_verifypeer', $this->sslVerifyPeer)
                        ->option('postfields', $data)
                        ->exec();

        return $this->_result($response);
    }
933351
public static function post($url, $data = [], $method = 'POST')
    {
        $ch = curl_init();

        if ( ! empty($data)) {
            $data = http_build_query($data);
        }
        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output

        $result = curl_exec($ch);
        
        curl_close($ch);

        if (false !== $result) {
            $result = json_decode($result);
            
        } else {
            throw new \Exception('Error during making request');
        }

        return $result;
    }
857782
public static function request($key = null, $type = 'string', $defaultValue = '')
    {
        if (!$key) {
            return array_merge($_GET, $_POST);
        }
        return self::typeConvert(isset($_REQUEST[$key]) ? $_REQUEST[$key] : $defaultValue, $type);
    }
322768
public static function doPost($url, $post_data = [], $timeout = 5, $header = "", $data_type = "")
    {
        if (empty($url) || empty($post_data) || empty($timeout))
            return false;
        if (!preg_match('/^(http|https)/is', $url))
            $url = "http://" . $url;
        $code = self::getSupport();
        switch ($code) {
            case 1:
                return self::curlPost($url, $post_data, $timeout, $header, $data_type);
                break;
            case 2:
                return self::socketPost($url, $post_data, $timeout, $header, $data_type);
                break;
            case 3:
                return self::phpPost($url, $post_data, $timeout, $header, $data_type);
                break;
            default:
                return false;
        }
    }
1006801
public function update($table, $data, $where = '')
    {
        $fieldDetails = null;
        foreach ($data as $key => $value) {
            $fieldDetails .= "$key = :$key,";
        }
        $fieldDetails = rtrim($fieldDetails, ',');
        $query = "UPDATE $table SET $fieldDetails ".($where ? 'WHERE '.$where : '');
        $this->prepare($query);

        foreach ($data as $key => $value) {
            $this->bind(":$key", $value);
        }
        try {
            $this->execute();

            return true;
        } catch (PDOException $e) {
            echo $e->errorInfo[2];

            return false;
        }
    }
797131
public function request($requestUrl, $data = [], $type = self::TYPE_POST)
    {
        $callUrl = $this->config->facebookApiUrl . $requestUrl;

        if($type === self::TYPE_GET) 
        {
            $callUrl .= '?' . $this->prepareData($data);
        }

        $curl = curl_init($callUrl);
        
        curl_setopt($curl, CURLOPT_TIMEOUT, 30);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $this->getHeaders());
        curl_setopt($curl, CURLOPT_HEADER, 0);
        
        if($type === self::TYPE_POST) 
        {
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $this->prepareData($data));
        }

        $response = new Response(curl_exec($curl));
        
        $curlError = curl_error($curl);
        if(!empty($curlError))
        {
            throw new MessengerPlatformException('Gate exception (curl error) #3: ' . $curlError);
        }
        
        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        if($statusCode != 200)
        {
            throw new MessengerPlatformException('Gate exception #2: ' . $response->error->message, 2);
        }
        
        curl_close($curl);

        return $response;
    }
172534
public function set($data=null, $where=null)
    {
        if ($data)  {
            $this->getQuery()->set('data', $data);
        }
        if ($where) {
            $this->where($where);
        }
        
        return $this;
    }
910695
public function request($addr, $type, $data, $cb)
    {
        $e = explode(':', $addr);
        $this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/',
            function ($conn) use ($cb, $addr, $data, $type) {
                if (!$conn->connected) {
                    $cb($conn, false);
                    return;
                }
                $conn->request($type, $data, $cb);
            });
    }
116536
public function execute(string $type, string $operation, array $parameters = [])
    {
        return $this->{$type}->{$operation}(...$parameters);
    }