Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- require_once('facebook.php');
- $randomimg = "https://XXXXXXX.herokuapp.com/randim.php";
- $facebook = new Facebook(array(
- 'appId'=>'XXXXX',
- 'secret'=>'XXXXXXXXXX',
- ));
- $session = $facebook->getUser();
- if($session)
- {
- try
- {
- $fbme = $facebook->api('/me');
- }
- catch(FacebookApiException $e)
- {
- echo 'error bei getsession';
- }
- } //if($session)
- #permissions
- if(!$fbme)
- {
- #access permission
- $loginUrl = $facebook->getLoginUrl(array(
- 'canvas' => 1,
- 'fbconnect' => 0,
- 'req_perms' => 'publish_stream',
- 'next' => 'https://XXX.herokuapp.com/index.php',
- 'cancel_url' => 'https://XXXXX.herokuapp.com/'
- ));
- echo '<script type="text/javascript">top.location.href=\''.$loginUrl.'\';</script>';
- } //else($fbme)
- #wall post
- try
- {
- $wallpost = $facebook->api('/me/feed','post',array(
- 'name' => 'Welche Konsole passt zu mir?',
- 'message' => 'Cool! Ich habe gerade herausgefunden, welche Konsole zu mir passt! Probiers doch auch mal aus! Einfach hier klicken!',
- 'privacy' => array(
- 'value' => 'CUSTOM',
- 'friends' => 'FRIENDS_OF_FRIENDS'
- ),
- 'description' => 'Diese Konsole passt zu mir! Probier es auch aus! Klick einfach hier!',
- 'picture' => '$randomimg',
- 'caption' => 'https://www.facebook.com/pages/XXX/XXXX?sk=app_1XXXXXX',
- 'link' => 'https://www.facebook.com/pages/XXXX/XXXXX?sk=app_XXXXX',
- 'action' => '';
- ));
- if($facebook->api('/me/feed/','post',$wallpost))
- {
- echo "Wenn du sehen möchtest, welche Konsole zu dir passt, dann schau auf der Startseite nach :) Es wurde für idch gepostet!";
- }
- }
- catch(FacebookApiException $e)
- {
- echo 'facebook api exception';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement