Home
> 2013, ajax, Economy, face book, Facebook, Facebook integration, google, internet, News, Open-source, pagination, Paypal, PHP, Plugin, political, Regional, Review, selvabalaji, seo, Social Network, software, software development, Twitter, Vijay Film, web services, Wordpress, World News, Yahoo > Upload Cover Photo to Facebook via PHP
Upload Cover Photo to Facebook via PHP
Here is a tutorial to upload a Cover Photo on Facebook via PHP. We will need Facebook Application ID and Secret, and Facebook files from Github.com then upload to your web space only the src folder. Now create a file called upload.php and upload it to your web space. Open upload.php with notepad and add this code:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => "xxxxxxxxxxxxxxxxxxx", //Facebook App ID
'secret' => "xxxxxxxxxxxxxxxxxxx", // 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://selvabalaji.wordpress.com/upload.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($_GET['cover']);
$args = array('message' => 'Uploaded from hhttp://selvabalaji.wordpress.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>";
?>
Now that just type in the URL of your site followed by the name of the image file and you’re done!
Example : http://yoursitename.com/upload.php?cover=selvabalaji.gif
Categories: 2013, ajax, Economy, face book, Facebook, Facebook integration, google, internet, News, Open-source, pagination, Paypal, PHP, Plugin, political, Regional, Review, selvabalaji, seo, Social Network, software, software development, Twitter, Vijay Film, web services, Wordpress, World News, Yahoo
Album cover, Facebook, Facebook Application ID, Facebook features, Github.com, Languages, PHP, Programming, selvabalaji, software, Uploading and downloading, Web hosting service
Comments (0)
Trackbacks (0)
Leave a comment
Trackback







Recent Comments