0
<?php
ob_start();
include("/home/coversco/public_html/include/config.php");
ini_set('display_errors', 1);
 error_reporting(E_ALL);


 require 'src/facebook.php';

 $facebook = new Facebook(array(
 'appId' => "xxxxxxxxxxxx", //Facebook App ID
 'secret' => "xxxxxxxxxxxx", // Facebook App Secret
 "cookie" => true,
 'fileUpload' => true
 ));

 $user_id = $facebook->getUser();

 if($user_id == 0 || $user_id == "")
 {
 $login_url = $facebook->getLoginUrl(array(
 'redirect_uri' => 'http://18covers.com/upload/index.php?cover='.$_GET['cover'].'', // Replace with your site url
 'scope' => "publish_stream,user_photos"));

 echo "<script type='text/javascript'>top.location.href = '$login_url';</script>";
 exit();
 }

 //get user album
 $albums = $facebook->api("/me/albums");
 $album_id = ""; 
 foreach($albums["data"] as $item){
 if($item["type"] == "cover_photo"){
 $album_id = $item["id"];
 break;
 }
 }

 //set timeline cover atributes 
 $full_image_path = realpath('{$purl}/t/l-{$p.pic}');
 $args = array('message' => 'Get awesome covers at www.18covers.com');
 $args['image'] = '@' . $full_image_path;

 //upload cover photo to Facebook
 $data = $facebook->api("/me/photos", 'post', $args);
 $picture = $facebook->api('/'.$data['id']);

 $fb_image_link = 'http://www.facebook.com/profile.php?preview_cover='.$data['id'].''; //redirect to uploaded facebook 

cover and change it
 echo "<script type='text/javascript'>top.location.href = '$fb_image_link';</script>";
?>

我已经建立了一个封面照片的网站,现在我正在尝试添加该功能,让用户通过单击按钮上传特定照片。但是我遇到了一个问题,问题是我已经为变量指定了图像的路径,图像的路径及其扩展名$full_image_path在哪里。{$purl}/t/l-{$p.pic}我需要输入目录中的路径还是 URL 路径。我输入的是 URL 路径,它抛出的错误是这个问题的标题。

如果有人告诉我正确的方向,我将不胜感激。

谢谢你。

4

0 回答 0