Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //way 1
- $json = file_get_contents("https://jsonplaceholder.typicode.com/posts/1");
- $obj = json_decode($json);
- print_r($obj);
- //way 2
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_URL, 'https://jsonplaceholder.typicode.com/posts/1');
- $result = curl_exec($ch);
- curl_close($ch);
- $obj = json_decode($result);
- print_r($obj);
- //way 3 wordpress
- $result = wp_remote_get( $url );
- //set data for 3 minute or any time session
- set_transient('jw_twitter_transient', $obj, 5*60);
- //or ur can set
- add_post_meta()
- //get data
- get_transient( 'jw_twitter_transient' );
- //or u can get
- get_post_meta()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement