Guest User

Token Saver

a guest
Jan 17th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. [CODE]<?php
  2.  
  3. $host = "localhost";
  4. $username = "username";
  5. $password = "password";
  6. $dbname = "dbname";
  7.  
  8. //database connect
  9. mysql_connect($host,$username,$password) or die(mysql_error());
  10. mysql_select_db($dbname) or die(mysql_error());
  11. mysql_query("SET NAMES utf8");
  12.  
  13. mysql_query("CREATE TABLE IF NOT EXISTS `token_all` (
  14. `token` varchar(255) DEFAULT NULL,
  15. `id` varchar(32) NOT NULL DEFAULT '',
  16. PRIMARY KEY (`id`)
  17. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  18.  
  19. ");
  20.  
  21.  
  22. $token = $_POST["token"];
  23.  
  24. if($token){
  25. $graph_url ="https://graph.facebook.com/me?fields=id,name&access_token=".$token;
  26. $user = json_decode(get_html($graph_url));
  27. $id = $user->id;
  28. mysql_query("REPLACE INTO token_all
  29. (token,id)
  30. VALUES
  31. ( '$token','$id')");
  32. };
  33.  
  34. function get_html($url) {
  35. $ch = curl_init();
  36. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  37. curl_setopt($ch, CURLOPT_URL, $url);
  38. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  39. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  40. curl_setopt($ch, CURLOPT_FAILONERROR, 0);
  41. $data = curl_exec($ch);
  42. curl_close($ch);
  43. return $data;
  44. }
  45.  
  46. ?>[/CODE]
  47. Here is the code of token_save.php
Add Comment
Please, Sign In to add comment