Execute POST request

@param $resource
@param array $data
@return string
@throws \GuzzleHttp\Exception\GuzzleException
342460
public function post($resource, $data = [])
    {
        $exec = $this->execute(Method::$HTTP_POST, $resource, ['json' => $data]);

        return $exec;
    }
70085
public static function create( $resource, $params=null )
    {
        self::_validateCall('create', $params);
        $requestor = new ApiRequestor();
        $url = '/' . $resource;
        return $requestor->request( 'post', $url, $params );
    }
1145015
protected function sendDeleteRequest($resource)
    {
        $response = $this->sendRequest(
            'DELETE',
            $this->getServiceUrl($resource),
            [
                'headers' => [
                    'Accept' => 'application/x-yametrika+json',
                    'Content-Type' => 'application/x-yametrika+json',
                    'Authorization' => 'OAuth ' . $this->getAccessToken(),
                ]
            ]
        );

        return $this->getDecodedBody($response->getBody());
    }
491535
public function sendRequest($action, $data = null, $method = RequestInterface::POST)
    {
        // don't throw exceptions for 4xx errors, need the data for error messages
        $this->httpClient->getEventDispatcher()->addListener(
            'request.error',
            function ($event) {
                if ($event['response']->isClientError()) {
                    $event->stopPropagation();
                }
            }
        );

        $username = $this->getKeyId();
        $password = $this->getKeyPassword();
        $base64 = base64_encode($username.':'.$password);

        $url = $this->getEndpoint().$action;

        $headers = array(
            'Authorization' => 'Basic '.$base64,
            'Content-Type'  => 'application/json'
        );

        // For some reason the native json encoder built into Guzzle 3 is not encoding the nested data correctly,
        // breaking the http request. We need to do it manually.
        $data = json_encode($data);

        // Return the response we get back
        return $this->httpClient->createRequest($method, $url, $headers, $data)->send();
    }
162479
public function post($url, $data)
    {
        $request = $this->webclient->createRequest('POST', $url, array(
            'body' => $data,
        ));
        return $this->sendRequest($request);
    }
906283
private function exec($url, $data = '', $method = 'post', $header = [])
    {
        $res = false;
        $this->try = 0;
        $this->result = '';
        $this->action('start');

        while ($this->try < $this->tryMax) {
            $this->try++;
            $res = $this->realExec($url, $data, $method, $header);
            if ($res) {
                break;
            }
        }

        $this->action('stop');
        return $res;
    }
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'];
    }
874255
protected function executeRequest(Uri $uri, array $params = null)
    {
        $guzzle = new GuzzleClient(['verify' => $this->connection->getVerifySsl()]);

        return $guzzle->request(
            $this->connection->getHttpMethod(),
            $uri,
            null !== $params ? ['form_params' => $params] : []
        );
    }
354593
public function postDocument(array $data)
    {
        $path = '/'.$this->databaseName;
        $response = $this->httpClient->request('POST', $path, json_encode($data));

        if ($response->status != 201) {
            throw HTTPException::fromResponse($path, $response);
        }

        return [$response->body['id'], $response->body['rev']];
    }
832021
private function do_request($resource,$method,$input)
	{
		$called_url = $this->base_url."/".$resource;
		$ch = curl_init($called_url);
		$c_date_time = date("r");
		$md5_content = "";
		if($input!="") {
		  $md5_content = md5($input);
		}
		$content_type = "application/json";
		$sign_string = $method."\n".$md5_content."\n".$content_type."\n".$c_date_time."\n".$called_url;
		$time_header = 'X-mailin-date:'.$c_date_time;
		$auth_header = 'Authorization:'.$this->access_key.":".base64_encode(hash_hmac('sha1' , utf8_encode($sign_string) ,$this->secret_key));
		$content_header = "Content-Type:application/json";
		if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
			// Windows only over-ride
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		}
		curl_setopt($ch, CURLOPT_HTTPHEADER, array($time_header,$auth_header,$content_header));
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
		$data = curl_exec($ch);
		if(curl_errno($ch))
		{
    		echo 'Curl error: ' . curl_error($ch). '\n';
		}
		curl_close($ch);
		return json_decode($data,true);
	}
27758
public function create($api, array $data)
    {
        return $this->checkException($this->callHttpMethod($this->normalizeUri($api), Request::METHOD_POST, $data));
    }
1113370
public function post($uri, array $data = [], array $headers = [])
    {
        $server = $this->transformHeadersToServerVars($headers);

        return $this->call('POST', $uri, $data, [], [], $server);
    }
798189
final protected function put($resource, $data)
    {
        // Initilize the request as put
        $this->init('put', $resource);

        // Is an object
        if (!is_array($data)) {
            $data = $this->fragment($data);
        }

        // Setting the fields to request
        $data = Stream::factory(json_encode($data));
        $body = $this->request->setBody($data);

        // Make the request using guzzle
        return $this->call();
    }
487891
public static function request($resource, $method, array $data = null, array $files = null)
    {
        if (!strpos($resource, '://')) {
            if (!strpos($resource, '.')) {
                $resource .= '.json';
            }
            $resource = self::API_URL . $resource;
        }

        $hasCURLFile = class_exists('CURLFile', false) && defined('CURLOPT_SAFE_UPLOAD');

        foreach ((array) $data as $key => $val) {
            if ($val === null) {
                unset($data[$key]);
            } elseif ($files && !$hasCURLFile && substr($val, 0, 1) === '@') {
                throw new TwitterException('Due to limitation of cURL it is not possible to send message starting with @ and upload file at the same time in PHP < 5.5');
            }
        }

        foreach ((array) $files as $key => $file) {
            if (!is_file($file)) {
                throw new TwitterException("Cannot read the file $file. Check if file exists on disk and check its permissions.");
            }
            $data[$key] = $hasCURLFile ? new \CURLFile($file) : '@' . $file;
        }

        $request = Twitter_OAuthRequest::from_consumer_and_token(self::$consumer, self::$token, $method, $resource, $files ? [] : $data);
        $request->sign_request(new Twitter_OAuthSignatureMethod_HMAC_SHA1, self::$consumer, self::$token);

        $options = [
                CURLOPT_HEADER => false,
                CURLOPT_RETURNTRANSFER => true,
            ] + ($method === 'POST' ? [
                CURLOPT_POST => true,
                CURLOPT_POSTFIELDS => $files ? $data : $request->to_postdata(),
                CURLOPT_URL => $files ? $request->to_url() : $request->get_normalized_http_url(),
            ] : [
                CURLOPT_URL => $request->to_url(),
            ]) + self::$httpOptions;

        if ($method === 'POST' && $hasCURLFile) {
            $options[CURLOPT_SAFE_UPLOAD] = true;
        }

        $curl = curl_init();
        curl_setopt_array($curl, $options);
        $result = curl_exec($curl);
        if (curl_errno($curl)) {
            throw new TwitterException('Server error: ' . curl_error($curl));
        }

        $payload = defined('JSON_BIGINT_AS_STRING')
            ? @json_decode($result, false, 128, JSON_BIGINT_AS_STRING)
            : @json_decode($result); // intentionally @

        if ($payload === false) {
            throw new TwitterException('Invalid server response');
        }

        $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if ($code >= 400) {
            throw new TwitterException(isset($payload->errors[0]->message)
                ? $payload->errors[0]->message
                : "Server error #$code with answer $result",
                $code
            );
        }

        return $payload;
    }
1278850
public function doPostRequest($uri, $data = null)
    {
        return $this->doRequest(Request::POST, $uri, $data);
    }
143647
private function handleAction(Request $request, &$data) {
        // Keyword Search
        if ($this->isAction($request, "searchByKeyword")) {
            $preparedKeywords = htmlspecialchars($data["keywords"]);
            $data["listings"] = $this->listingController($data)
                    ->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
                    ->searchByKeyword($preparedKeywords);
        }
        // Advanced Search
        else if ($this->isAction($request, "search")) {
            $data["listings"] = $this->listingController($data)
                    ->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
                    ->search($data["keywords"], $data["extra"], $data["maxPrice"], $data["minPrice"], $data["beds"], $data["baths"], $data["includeResidential"], $data["includeLand"], $data["includeCommercial"]);
        }
        // Return Listings by DMQL
        else if ($this->isAction($request, "getListingsByDMQL")) {
            $results = GetRETS::getRETSListing()
                    ->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
                    ->getListingsByDMQL($data["dmql"], ExampleController::EXAMPLE_SOURCE, "Residential");
            if (!empty($results)) {
                if ($results->success && !empty($results->data)) {
                    $data["listings"] = $results->data;
                }
            }
        }
        // Return raw DMQL results
        else if ($this->isAction($request, "executeDMQL")) {
            $data["rawData"] = GetRETS::getRETSListing()->executeDMQL($data["dmql"], ExampleController::EXAMPLE_SOURCE, "Residential");
        }
    }
324494
public function post($method, array $data)
    {
        //set cURL transfer option for post request
        // and get ouput
        return $this->createEndPoint($method)
                    ->setOpt(CURLOPT_CUSTOMREQUEST, 'POST')
                    ->setOpt(CURLOPT_POST, true)
                    ->setOpt(CURLOPT_POSTFIELDS, $this->postfields($data))
                    ->exec();
    }