Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    12

    Problema nella creazione di un API per Facebook

    Ciao ragazzi, è da un po' che non scrivo. Definirmi "programmatore" è un cortesissimo eufemismo, in ogni caso per necessità personali tento di sviluppare da qualche giorno una applicazione per facebook che mi permetta di pubblicare la medesima foto su più fan page con un comando. Ciò che sono riuscito con le mie sole capacità ad ottenere, tuttavia, è questo script
    Codice PHP:
    <html>
        <head>
        <title>Notipedia</title>
        <link href="style.css" rel="stylesheet" type="text/css" />
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        </head>
         
        <body>
        <?php
        
    require_once 'src/facebook.php';
        
    $facebook = new Facebook(array(
         
    'appId'  => 'xxxxxxxxxxxxxx',
         
    'secret' => 'xxxxxxxxxxxxx',
         
    'fileUpload' => true
        
    ));
         
         
        
    //It can be found at [url]https://developers.facebook.com/tools/access_token/[/url]
        
    $access_token ='xxxxxxxxxxxxxxxxxxxxx';
         
        
    $params = array('access_token' => $access_token);
         
        
    //The id of the fanpage
        
    $fanpage ='xxxxxxxxxxxxx';
         
        
    //The id of the album
        
    $album_id ='xxxxxxxx-id1';
        
    $album_id ='xxxxxxxx-id2';
        
    $accounts $facebook->api('/xxxxxxxx/accounts''GET'$params);
         
        foreach(
    $accounts['data'] as $account) {
         if( 
    $account['id'] == $fanpage || $account['name'] == $fanpage ){
          
    $fanpage_token $account['access_token'];
         }
        }
         
         
        
    $valid_files = array('image/jpeg''image/png''image/gif');
         
        if(isset(
    $_FILES) && !empty($_FILES)){
         if( !
    in_array($_FILES['pic']['type'], $valid_files ) ){
          echo 
    'Only jpg, png and gif image types are supported!';
         }else{
          
    #Upload photo here
          
    $img realpath($_FILES["pic"]["tmp_name"]);
         
          
    $args = array(
           
    'message' => 'Diventa fan di ',
           
    'image' => '@' $img,
           
    'aid' => $album_id,
           
    'no_story' => 1,
           
    'access_token' => $fanpage_token
          
    );
         
          
    $photo $facebook->api($album_id '/photos''post'$args);
          if( 
    is_array$photo ) && !empty( $photo['id'] ) ){
           echo 
    '

    [url="http://www.facebook.com/photo.php?fbid='
    .$photo['id'].'"]Click here to watch this photo on Facebook.[/url]</p>';
          }
         }
        }
         
        
    ?>
         
         <div class="main">
          

    Select a photo to upload on Facebook Fan Page</p>
          <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
          

    Select the image: <input type="file" name="pic" /></p>
          

    <input class="post_but" type="submit" value="Upload to my album" /></p>
          </form>
         </div>
        </body>
        </html>
    http://pastebin.com/rMGvC8JN

    Che mi permette di caricare 1 foto su 1 solo album per volta e non viene visualizzata sulla bacheca. Qualcuno dotato di buona pazienza saprebbe darmi una mano?[PHP]

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    12
    Nessuno?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.