Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. function call_for_api() {
  2.  
  3.  
  4. $url='https://api-v2.weedmaps.com/api/v2/listings';
  5. $response = wp_remote_post( $url, array(
  6. 'timeout' => 45,
  7. 'redirection' => 5,
  8. 'httpversion' => '1.0',
  9. 'blocking' => true,
  10. 'headers' => array('accept'=>'application/json','accept-encoding' => 'gzip, deflate, br','connection' =>'keep-alive'),
  11. 'body' => null,
  12. 'cookies' => array(),
  13. 'compress' => false,
  14. 'decompress' => true,
  15. 'sslverify' => true,
  16. 'stream' => false,
  17. 'filename' => null,
  18. 'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0'
  19. )
  20. );
  21.  
  22. if ( is_wp_error( $response ) ) {
  23. $error_message = $response->get_error_message();
  24. echo "Something went wrong: $error_message";
  25. } else {
  26. echo 'Response:<pre>';
  27. print_r( $response );
  28. echo '</pre>';
  29. echo wp_remote_retrieve_body( $response );
  30.  
  31. }
  32. }
  33.  
  34. function cf_shortcode() {
  35. ob_start();
  36. call_for_api();
  37.  
  38. return ob_get_clean();
  39. }
  40.  
  41. add_shortcode( 'weed-list', 'cf_shortcode' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement