Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php formData curl

/**
     * post curl with array post fields
     *
     * @param Array $postFields
     * @return boolean
     */
    private function formDataCurl(array $postFields, string $url, $form = false)
    {
        $post = $postFields;
        if (count($post) == 0) {
            return false;
        }

        $url = trim($url);



        $postdata = $post;
        if ($form == false) {
            $postdata = json_encode($post, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        }


        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        if ($form == false) {
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        }
        $result = curl_exec($ch);
        curl_close($ch);

        return $decodedResult = json_decode($result, JSON_UNESCAPED_UNICODE);
    }
Comment

PREVIOUS NEXT
Code Example
Php :: check if string contains substring php 8 
Php :: Malformed UTF-8 characters, possibly incorrectly encoded 
Php :: get specific columns using with() function in laravel eloquent 
Php :: get post info in php 
Php :: execute php in terminal 
Php :: Install Older Version of Laravel using Composer 
Php :: thousand seperator php 
Php :: check installed php modules in linux 
Php :: eloquent unique combination 
Php :: laravel query builder select 
Php :: filter child table data from parent laravel eloquent 
Php :: loop iteration laravel 
Php :: setup cron on macos for laravel 
Php :: filter collection (laravel) 
Php :: string match percentage php 
Php :: php get keys of duplicate values in array 
Php :: how to display the database table names list in codeigniter 
Php :: foreach date php 
Php :: php number to words 
Php :: implode example in php 
Php :: where is phpinfo() 
Php :: taxonomy_get_parents drupal 8 
Php :: wp php go back 
Php :: insert multiple rows laravel 
Php :: password_verify php 
Php :: change the method name in resource in laravel 
Php :: axios post not sending data php 
Php :: laravel parent child relationship in same table 
Php :: php array filter specific keys 
Php :: how to upload two files on same form different path in codeigniter 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =