Upload Facebook Covers to Facebook using JavaScript is possible, this is the script:
<?php
$url= $_GET['url'];
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>Upload Facebook Covers to Facebook via Javascript</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p id='msg'></p>
<script type="text/javascript">
FB.init({appId: "xxxxxxxxx", status: true, cookie: true})function Login() {
FB.login(function(response) {
if (response.authResponse) {
var access_token = FB.getAuthResponse()['accessToken'];
console.log('Access Token = '+ access_token);
FB.api('me/photos', 'post', {
message: 'http://socialdevelopers.wordpress.com/',
status: 'success',
access_token: access_token,
url: '<?php echo $url; ?>'
}, function (response) {
if (!response || response.error) {
alert('Error occured:' + response);
} else {
alert('Cover uploaded');
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'user_photos,photo_upload,offline_access,publish_actions,email,read_stream,publish_stream,user_birthday,user_location,user_hometown,friends_birthday,friends_location'});
};
</script>
<a href="#" onclick="Login();">upload to facebook</a>
</body>
</html>
Now that just type in the URL of your site followed by the name of the image file and you’re done!
For example: http://socialdevelopers.wordpress.com/upload.php?url=image.jpg
Related articles
- Upload Cover Photo to Facebook via PHP (socialdevelopers.wordpress.com)
- Client-side photo access with access_token, using Facebook graph (stackoverflow.com)
- 2013 Facebook Timeline Covers (covertimeline.wordpress.com)
- Facebook Covers (99cover.wordpress.com)
- 2013 Facebook Covers (firstcovers.wordpress.com)