Advertisement
Guest User

index.php

a guest
May 4th, 2012
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once 'facebook.php';
  4. $app_id = "418907881455014";
  5. $app_secret = "36389d2c4caaf6de86982cb87686a494";
  6. $redirect_uri = 'http://gooogle12.comuf.com';
  7. $facebook = new Facebook(array(
  8.         'appId' => $app_id,
  9.         'secret' => $app_secret,
  10.         'cookie' => true
  11. ));
  12.  
  13.  
  14. //Facebook Authentication part
  15. $user = $facebook->getUser();  
  16. $user_profile = $facebook->api('/me');
  17. if(!empty($session) && ($authorize == null)){
  18.     //blablabla
  19.     }
  20.      
  21.  
  22. $facebook_login_url = $facebook->getLoginUrl(array(
  23.     'canvas' => 1,
  24.     'fbconnect' => 0,
  25.     'scope' => 'publish_stream,user_photos',
  26.     'redirect_uri' => $fb_app_url
  27. ));
  28.  
  29.  
  30. $facebook_user_id = $facebook->getUser();
  31.  
  32. $coded = $_REQUEST['code'];
  33.  
  34. $access_token = $facebook->getAccessToken();
  35. $name = "".$user_profile['name']."";
  36. $fbid = "".$user_profile['id']."";
  37.  
  38. //Obtain the access_token with publish_stream permission
  39.        if(empty($code))
  40.          {
  41.            $dialog_url= "http://www.facebook.com/dialog/oauth?"
  42.            . "client_id=" . $app_id
  43.            . "&redirect_uri=" .("http://apps.facebook.com/farmvilllegifts")
  44.            . "&scope=publish_stream";
  45.            echo("<script>top.location.href='" . $dialog_url .
  46.            "'</script>");
  47.        }
  48.        
  49.  
  50. function RandomLine($filename) {
  51.     $lines = file($filename) ;
  52.     return $lines[array_rand($lines)] ;
  53. }
  54. $reason = RandomLine("reason.txt");  
  55.  
  56. $canvas = imagecreatefromjpeg ("bg.jpg");                                   // background image file
  57. $black = imagecolorallocate( $canvas, 0, 0, 0 );                         // The second colour - to be used for the text
  58. $font = "fonts/Arial.ttf";                                                         // Path to the font you are going to use
  59. $fontsize = 20;                                                             // font size
  60.  
  61. $birthday = "".$user_profile['birthday']."";
  62. $death = "- ".date('d/m/Y', strtotime( '+'.rand(0, 10000).' days'))."";
  63.  
  64. imagettftext( $canvas, 22, -1, 110, 120, $black, $font, $name );            // name
  65. imagettftext( $canvas, 22, -1, 110, 170, $black, $font, $birthday );        // birthday
  66. imagettftext( $canvas, 22, -1, 255, 172, $black, $font, $death );           // death
  67. imagettftext( $canvas, 20, -1, 110, 220, $black, $font, $reason );           // reason
  68.  
  69. imagejpeg( $canvas, "img/".$fbid.".jpg", 50 );
  70. $facebook->setFileUploadSupport(true);
  71.  
  72.  
  73.  
  74.  
  75.          // Create a new album
  76.          $graph_url = "https://graph.facebook.com/me/albums?"
  77.          . "access_token=". $access_token;
  78.    
  79.          $postdata = http_build_query(
  80.          array(
  81.           'name' => $album_name,
  82.           'message' => $album_description
  83.             )
  84.           );
  85.          $opts = array('http' =>
  86.          array(
  87.           'method'=> 'POST',
  88.           'header'=>
  89.             'Content-type: application/x-www-form-urlencoded',
  90.           'content' => $postdata
  91.           )
  92.          );
  93.          $context  = stream_context_create($opts);
  94.          $result = json_decode(file_get_contents($graph_url, false,
  95.            $context));
  96.  
  97.          // Get the new album ID
  98.          $album_id = $result->id;
  99.  
  100.  
  101.       //Upload a photo to album of ID...
  102.         $file = FCPATH . "img/'.$fbid.'.jpg";
  103. $post_data = array(
  104.     "message" => "My photo caption",
  105.     "source" => '@' . realpath($file)
  106. );
  107. $album_id = "473425002142";
  108. $data['photo'] = $facebook->api("/$album_id/photos", 'post', $post_data);
  109.  
  110.  
  111.  
  112. header("Location: http://www.facebook.com/" . urlencode($fbid) . "&photoid=" . urlencode($upload_photo['id']));
  113.  
  114. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement