Advertisement
Guest User

Untitled

a guest
Oct 18th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. $opts = array(
  2. 'http'=>array(
  3. 'method'=>"GET",
  4. 'header'=>"Authorization: Bearer {$access_token}rn",
  5. 'Content-Type'=>"application/x-www-form-urlencoded"));
  6.  
  7. $context = stream_context_create($opts);
  8. // Open the file using the HTTP headers set above
  9. $response = file_get_contents($url, false, $context);
  10. $user = json_decode($response, true);
  11. return $user['data'];
  12. }
  13. // open mysql connection
  14. $host = "localhost";
  15. $username = "root";
  16. $password = "5984";
  17. $dbname = "test";
  18. $con = mysqli_connect($host, $username, $password, $dbname);
  19.  
  20. if(mysqli_connect_errno($con)){
  21. echo "fail!";
  22. }
  23. else{
  24. echo "success!";
  25. $result = mysqli_query($con, "select * from testtable");.
  26. while($row = mysqli_fetch_array($result)){
  27. echo $row['column1'];
  28. echo " ";
  29. }}
  30.  
  31. foreach($user as $item){
  32. mysqli_query($con, "INSERT INTO testtable (column1, column2, column3,column4,
  33. column5) VALUES ('".$item['time_updated']."','".$item['time_created']."',
  34. '".$item['date']."','".$item['resting_heartrate']."', '".$item['place_lat']."')");}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement