Advertisement
P22DX

curl_ffi.php

Jun 11th, 2020
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. $libcurl = FFI::cdef(
  4.     <<< CDEF
  5. void *curl_easy_init();
  6. int curl_easy_setopt(void *curl, int Options, ...);
  7. int curl_easy_perform(void *curl);
  8. void curl_easy_cleanup(void *handle);
  9. CDEF,
  10.    
  11.     'libcurl.so'
  12. );
  13.  
  14. $url = 'https://nasa.gov';
  15. $ch  = $libcurl->curl_easy_init();
  16. $libcurl->curl_easy_setopt($ch, CURLOPT_URL, $url);
  17. $libcurl->curl_easy_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  18. $libcurl->curl_easy_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  19. $libcurl->curl_easy_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  20. $result = $libcurl->curl_easy_perform($ch);
  21. $libcurl->curl_easy_cleanup($ch);
  22.  
  23. var_dump($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement