Skip to content

Instantly share code, notes, and snippets.

@halityurttas
Last active April 10, 2021 12:15
Show Gist options
  • Save halityurttas/b984c5925968c8946e8ab04d4d0a9f12 to your computer and use it in GitHub Desktop.
Save halityurttas/b984c5925968c8946e8ab04d4d0a9f12 to your computer and use it in GitHub Desktop.
Curl initialize func
<?php
public function get_curl_instance($url, $headers, $fields = null, $is_post = false) {
$curl = curl_init($url);
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_HEADER, true );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
if ( $fields )
curl_setopt( $curl, CURL_POSTFIELDS, $fields );
if ( $is_post )
curl_setopt( $curl, CURLOPT_POST, true );
return $curl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment