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>";
?>

I have built a cover photo's site and now i am trying to add the feature to let users upload the specific photo with a button click. But i am stuck with a problem, Problem is that i have specified the path to image to the variable $full_image_path, Where {$purl}/t/l-{$p.pic} is the path to image with its extension. Do i need to enter the path which is in directory or an URL path. The one i have entered is URL path and its throwing the error which is the title of this question.

I would appreciate if someone shows me the right direction.

Thank You.

Nishant Ghodke
  • 923
  • 1
  • 12
  • 21
  • Possible duplicate of http://stackoverflow.com/questions/8568785/getting-fatal-error-uncaught-curlexception-26-couldnt-open-file – Hanky Panky Mar 04 '13 at 08:44
  • _“Do i need to enter the path which is in directory or an URL path.”_ – why do you think the error message speaks of a “file”? Exactly, because the file system and HTTP are two completely different things … – CBroe Mar 04 '13 at 15:58

0 Answers0