Advertisement
ShawnsSpace

Facebook Application Token by cURL

Nov 21st, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2. function GetCH(){
  3. $ch = curl_init();
  4. curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/oauth/access_token?client_id=YourAppId&client_secret=YOUR_APP_SECRET&grant_type=client_credentials");
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  7. //curl_setopt($ch,CURLOPT_CONNECTTIMEOUT_MS,20000);
  8. if(substr($url,0,8)=='https://'){
  9.     // The following ensures SSL always works. A little detail:
  10.     // SSL does two things at once:
  11.     //  1. it encrypts communication
  12.     //  2. it ensures the target party is who it claims to be.
  13.     // In short, if the following code is allowed, CURL won't check if the
  14.     // certificate is known and valid, however, it still encrypts communication.
  15.     curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
  16.     curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
  17. }
  18. $sendCH = curl_exec($ch);
  19. curl_close($ch);
  20. return $sendCH;
  21. };
  22.  
  23. $app_token = GetCH();
  24. print_r(GetCH())
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement