Advertisement
Guest User

Untitled

a guest
Aug 26th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. require_once('facebook.php');
  4. $randomimg = "https://XXXXXXX.herokuapp.com/randim.php";
  5. $facebook = new Facebook(array(
  6.       'appId'=>'XXXXX',
  7.       'secret'=>'XXXXXXXXXX',
  8.     ));
  9. $session = $facebook->getUser();
  10. if($session)
  11. {  
  12.  try
  13.  {  
  14.   $fbme = $facebook->api('/me');
  15.  }
  16.  catch(FacebookApiException $e)
  17.  {
  18.   echo 'error bei getsession';
  19.  }  
  20. } //if($session)
  21.  
  22. #permissions
  23. if(!$fbme)
  24. {
  25.  #access permission
  26. $loginUrl = $facebook->getLoginUrl(array(
  27.   'canvas'     => 1,
  28.   'fbconnect'  => 0,
  29.   'req_perms'  => 'publish_stream',
  30.   'next'       => 'https://XXX.herokuapp.com/index.php',
  31.   'cancel_url' => 'https://XXXXX.herokuapp.com/'
  32.  ));
  33.  echo '<script type="text/javascript">top.location.href=\''.$loginUrl.'\';</script>';
  34. } //else($fbme)
  35.  
  36. #wall post
  37. try
  38. {
  39.  $wallpost = $facebook->api('/me/feed','post',array(
  40.   'name'        => 'Welche Konsole passt zu mir?',
  41.   'message'     => 'Cool! Ich habe gerade herausgefunden, welche Konsole zu mir passt! Probiers doch auch mal aus! Einfach hier klicken!',
  42.   'privacy'     => array(
  43.    'value'   => 'CUSTOM',
  44.    'friends' => 'FRIENDS_OF_FRIENDS'
  45.   ),
  46.   'description' => 'Diese Konsole passt zu mir! Probier es auch aus! Klick einfach hier!',
  47.   'picture'     => '$randomimg',
  48.   'caption'     => 'https://www.facebook.com/pages/XXX/XXXX?sk=app_1XXXXXX',
  49.   'link'        => 'https://www.facebook.com/pages/XXXX/XXXXX?sk=app_XXXXX',
  50.   'action'      => '';
  51.  ));
  52.  if($facebook->api('/me/feed/','post',$wallpost))
  53.  {
  54.   echo "Wenn du sehen möchtest, welche Konsole zu dir passt, dann schau auf der Startseite nach :) Es wurde für idch gepostet!";
  55.  }
  56. }
  57. catch(FacebookApiException $e)
  58. {
  59.  echo 'facebook api exception';
  60. }
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement