English 中文(简体)
在Facebook上载照片并制作一个册。 下载后将用户转至另一个网页,带上照片
原标题:Upload photo on Facebook and create an album. After the download redirect the user to another page with the photo presented

The bellow Code出价。 它卸下一台照片,并生成新的照片。 很显然,我不知道如何将其转移到某个地方,最后用一个带有“红字”的空白页。 我想要把直接连接起来,而照片的这种间接联系也应呈报。 我希望用户在光电后重新定位。 当用户在上载纽顿时,照片上载。

 $post_login_url = "http://apps.facebook.com/firstestt/upload.processor.php";
   $album_name =  Facepic Album ;
   $album_description =  http://apps.facebook.com/firstestt/ ;


   $code = $_REQUEST["code"];
$facebook->setFileUploadSupport(true);
   //Obtain the access_token with publish_stream permission 
   if(empty($code))
     {
       $dialog_url= "http://www.facebook.com/dialog/oauth?"
       . "client_id=" . $app_id 
       . "&redirect_uri=" . urlencode($post_login_url)
       . "&scope=publish_stream";
       echo("<script>top.location.href= " . $dialog_url . 
       " </script>");
   } 
   else {
     $token_url= "https://graph.facebook.com/oauth/"
     . "access_token?"
     . "client_id=" .  $app_id 
     . "&redirect_uri=" . urlencode( $post_login_url)
     . "&client_secret=" . $app_secret
     . "&code=" . $code;
     $response = file_get_contents($token_url);
     $params = null;
    parse_str($response, $params);
     $access_token = $facebook->getAccessToken();

     // Create a new album
     $graph_url = "https://graph.facebook.com/me/albums?"
     . "access_token=". $access_token;

     $postdata = http_build_query(
     array(
       name  => $album_name,
       message  => $album_description
        )
      );
     $opts = array( http  =>
     array(
       method =>  POST ,
       header =>
         Content-type: application/x-www-form-urlencoded ,
       content  => $postdata
      )
     );
     $context  = stream_context_create($opts);
     $result = json_decode(file_get_contents($graph_url, false, 
       $context));

     // Get the new album ID
     $album_id = $result->id;

     //Show photo upload form and post to the Graph URL
     $graph_url = "https://graph.facebook.com/". $album_id
       . "/photos?access_token=" . $access_token;
     echo  <html><body> ;
     echo  <form enctype="multipart/form-data" action=" 
     .$graph_url.   "method="POST"> ;
     echo  Adding photo to album:   . $album_name . <br/><br/> ;
     echo  Please choose a photo:  ;
     echo  <input name="source" type="file"><br/><br/> ;
     echo  Say something about this photo:  ;
     echo  <input name="message" type="text"
        value=""><br/><br/> ;
 //When this button is pressed the page should upload the photo and redirect the user to another link  
     echo  <input type="submit" value="Upload"  /><br/> ; 
     echo  </form> ;
     echo  </body></html> ;
  }
问题回答

我想this article对你的需求作了准确的调整。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebSpeaks.in | Upload images to Facebook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
html{
    font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
}
.main{
    width:400px;
    margin:auto;
    border:2px solid #0066CC;
    color:#3B5998;
    padding:20px;
    font-size: 11px;
    -moz-border-radius: 4px 4px 4px 4px;
    border-radius: 4px 4px 4px 4px;
    -moz-box-shadow: 1px 1px 0 #d5d5d5;
    background: none repeat scroll 0 0 #F2F2F2;
}
.post_but {
    background: none repeat scroll 0 0 #EEEEEE;
    border-color: #999999 #999999 #888888;
    border-style: solid;
    border-width: 1px;
    color: #333333;
    cursor: pointer;
    display: inline-block;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    text-align: center;
    text-decoration: none;
}
a{
    color:#3B5998;
}
</style>
</head>

<body>
<?php
/******************Configuration options***********************/

require_once  library/facebook.php ;
$facebook = new Facebook(array(
   appId   => $appId,   //your facebook application id
   secret  => $secret,  //your facebook secret code
   cookie  => true
));

$user = $facebook->getUser();

if(is_null($facebook->getUser()))
{
    header("Location:{$facebook->getLoginUrl(array( req_perms  =>  user_status,publish_stream,user_photos ))}");
    exit;
}
/******************Configuration options***********************/

if($_SERVER[ REQUEST_METHOD ] == POST ){
    $img = realpath($_FILES["pic"]["tmp_name"]);
    // allow uploads
    $facebook->setFileUploadSupport("http://" . $_SERVER[ SERVER_NAME ]);
    // add a status message
    $photo = $facebook->api( /me/photos ,  POST , 
        array(
             source  =>  @  . $img,
             message  =>  This photo was uploaded via www.WebSpeaks.in 
        )
    );

    echo  <p><a target="_blank" href="http://www.facebook.com/photo.php?fbid= .$photo[ id ]. ">Click here to watch this photo on Facebook.</a></p> ;
}
?>
<div class="main">
    <p>Select a photo to upload on Facebook.</p>
    <form method="post" action="<?php echo $_SERVER[ PHP_SELF ]; ?>" enctype="multipart/form-data">
    <p>Select the image: <input type="file" name="pic" /></p>
    <p><input class="post_but" type="submit" value="Upload to my album" /></p>
    </form>
</div>
</body>
</html>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签