Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook API图形和上传照片_Facebook_Facebook Graph Api - Fatal编程技术网

Facebook API图形和上传照片

Facebook API图形和上传照片,facebook,facebook-graph-api,Facebook,Facebook Graph Api,我的网站上有一个Facebook的照片上传功能。请参阅下面的代码 上传照片后,我在Facebook上看到一个页面,结果如下: { "id": "3701830342510", "post_id": "1177996068_3701808141955" } 我想要的是上传程序将被转移到相册 <?php $app_id = "233929"; $app_secret = "9f3fa8e1e0be4254e0"; $post_login

我的网站上有一个Facebook的照片上传功能。请参阅下面的代码

上传照片后,我在Facebook上看到一个页面,结果如下:

{
   "id": "3701830342510",
   "post_id": "1177996068_3701808141955"
}
我想要的是上传程序将被转移到相册

 <?php
       $app_id = "233929";
       $app_secret = "9f3fa8e1e0be4254e0";
       $post_login_url = "http://";
       $album_name = 'My photos';
       $album_description = 'Photos submitted by the members of ';

       $code = $_REQUEST["code"];

       //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 = $params['access_token'];

         // Get the new album ID
         $album_id = 3597407572006;

         //Show photo upload form and post to the Graph URL
         $graph_url = "https://graph.facebook.com/". $album_id
           . "/photos?access_token=" . $access_token;
         echo '<form enctype="multipart/form-data" action="'
         .$graph_url. ' "method="POST">';
         echo 'Adding photo to : ' . $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/>';
         echo '<input type="submit" value="Upload photo" /><br/>';
         echo '</form>';
      }
 ?>

我怀疑你从官方博客帖子中获取的代码使用facebook graph api url进行表单操作,因此你在上传图片时会看到该页面。
你无法控制

您可以使用自己的url作为表单操作,然后使用php将pic上传到facebook,并将用户重定向到您想要的任何位置。 比如: