Build Post Data

@access public
@param  $data

@return array|string
515932
public function buildPostData($data)
    {
        $binary_data = false;
        if (is_array($data)) {
            // Return JSON-encoded string when the request's content-type is JSON.
            if (isset($this->headers['Content-Type']) &&
                preg_match($this->jsonPattern, $this->headers['Content-Type'])) {
                $json_str = json_encode($data);
                if (!($json_str === false)) {
                    $data = $json_str;
                }
            } else {
                // Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch,
                // CURLOPT_POSTFIELDS, $data) doesn't correctly handle multi-dimensional arrays when files are
                // referenced.
                if (self::is_array_multidim($data)) {
                    $data = self::array_flatten_multidim($data);
                }

                // Modify array values to ensure any referenced files are properly handled depending on the support of
                // the @filename API or CURLFile usage. This also fixes the warning "curl_setopt(): The usage of the
                // @filename API for file uploading is deprecated. Please use the CURLFile class instead". Ignore
                // non-file values prefixed with the @ character.
                foreach ($data as $key => $value) {
                    if (is_string($value) && strpos($value, '@') === 0 && is_file(substr($value, 1))) {
                        $binary_data = true;
                        if (class_exists('CURLFile')) {
                            $data[$key] = new \CURLFile(substr($value, 1));
                        }
                    } elseif ($value instanceof \CURLFile) {
                        $binary_data = true;
                    }
                }
            }
        }

        if (!$binary_data && (is_array($data) || is_object($data))) {
            $data = http_build_query($data, '', '&');
        }

        return $data;
    }
175256
public function buildPostBody($data = null) {
        $reqBody = ($data !== null) ? $data : $this->request_body;


        $this->request_body = (string) $reqBody;
    }
594328
public function sendData($data)
    {
        $httpResponse = $this->httpClient->post(
            $this->getEndpoint(),
            ['Content-Type' => 'text/xml; charset=utf-8'],
            $this->xmlSerialize($data)
        )->send();

        return $this->response = $this->newResponse( $httpResponse->xml() );
    }
1291938
public function sendData($data)
    {
        // Issue #20 no data values should be null.

        array_walk($data, function (&$value) {
            if (! isset($value)) {
                $value = '';
            }
        });

        $httpResponse = $this
            ->httpClient
            ->request(
                'POST',
                $this->getEndpoint(),
                [
                    'Content-Type' => 'application/x-www-form-urlencoded',
                ],
                http_build_query($data)
            );

        // We might want to check $httpResponse->getStatusCode()

        $responseData = static::parseBodyData($httpResponse);

        return $this->createResponse($responseData);
    }
392474
public function store($data)
    {
        $message = $this->client->post(
            sprintf('buckets/%d/message_boards/%d/messages.json', $this->bucket, $this->parent),
            [
                'json' => $data,
            ]
        );

        return new Message($this->response($message));
    }
11885
public function create($data)
    {
        $response = $this->restClient->post($this->endpoint, $data);
        return $response['body'];
    }
572952
public function massFactory($data)
    {
        $results = [];
        foreach ($data as $post) {
            $results[] = $this->factory($post);
        }
        return $results;
    }
849844
protected function prepareData($data)
    {
        $data['auth_key'] = $this->api_key;
        $data['format'] = $this->api_format;
        $data['pretty'] = $this->api_pretty;

        return $data;
    }
1161052
protected function returnData($data)
    {
        if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
            $this->returnJson([
                'success' => true,
                'data' => $data,
            ]);
        } else {
            $this->setData('breadcrumbs', $data);
            $this->setView('blocks/breadcrumbs.tpl', 'tao');
        }
    }
577992
public static function getManualInputPosts($data)
    {
        $posts = array();

        foreach ($data as $key => $item) {
            $posts[] = array_merge((array)$item, array(
                'ID' => $key,
                'post_name' => $key,
                'post_excerpt' => $item->post_content
            ));
        }

        $posts = json_decode(json_encode($posts));

        return $posts;
    }
324610
public function build(array $data = [])
    {
        if(!$this->oAuth2Credential)
            $this->oAuth();

        $data = $this->mergeData($data);

        $adwordsSession = new AdWordsSessionBuilder();

        return $adwordsSession->withDeveloperToken($data['developerToken'])
                ->withClientCustomerId($data['clientCustomerId'])
                ->withOAuth2Credential($this->oAuth2Credential)
                ->build();
    }
863520
public function sendData($data)
    {
        $method = $this->getRequestMethod();
        $url    = $this->getRequestUrl($data);
        $body   = $this->getRequestBody();

        $headers = [
            'Content-Type' => 'application/x-www-form-urlencoded'
        ];

        $response = $this->httpClient->request($method, $url, $headers, $body);

        $payload = $this->decode($response->getBody());

        return $payload;
    }
1236154
public function build(array $data = array())
    {
        $data += array(
            'page' => 1,
            'limit' => 0,
            'total' => 0,
            'mini' => false,
            'max_pages' => 10,
            'query' => array()
        );

        $this->setPage($data['page'])
            ->setPerPage($data['limit'])
            ->setTotal($data['total'])
            ->setMaxPages($data['max_pages'])
            ->setUrlPattern('?' . urldecode(http_build_query($data['query'])));

        return $this;
    }
26524
protected function buildUrl(array $data = []): string
    {
        $params = array_merge([
            'SM_API_KEY' => $this->api_key,
            'SM_LENGTH' => $this->summary_length,
        ], $data);

        $url  = 'http://api.smmry.com';
        $url .= '?' . http_build_query($params);

        return $url;
    }
308166
protected function _buildAuth($data)
    {
        $out = 'OAuth ';
        $params = [];
        foreach ($data as $key => $value) {
            $params[] = $key . '="' . $this->_encode($value) . '"';
        }
        $out .= implode(',', $params);

        return $out;
    }
285150
public function build_post_data($params) {
        $result = [];
        foreach ($params as $name => $value) {
            $result[] = urlencode($name) . '=' . urlencode($value);
        }
        return implode('&', $result);
    }
794333
protected function prepareData($data)
    {
        if(!is_array($data))
        {
            $data = [];
        }
        
        $data['access_token'] = $this->config->accessToken;
        
        return http_build_query($data);
    }