Create App Upload Picture to Facebook
ok liat demonya biar nyambung http://naxdevil.16mb.com
sebelum lanjut Pastikan hos u Supot Php : ok silahkan pilih salah satu
hos FREE yg supot php di bawah ini
http://www.idhostinger.com/
http://byethost.com/index.php/
http://000space.com/
http://www.freewebhostingarea.com/
download perlengkapan appsnya www.facebook.com/download/401407599920217/Upload%20Foto.zip
tu udah satu paket tinggal upload di hos kamu ,liat gambar nya
http://naxdevil.16mb.com/untitled.bmp
ok kalau udah edit source code index.php nya FILE INI YG NANTI DI TARUH DI Canvas URL
<?php
$loggedIn = false;
$is_error = false;
//Please fill the following variables with your Facebook App specific data
$app_id = 'YOUR_APP_ID';
$client_id = 'YOUR_APP_SECRET';
$access_token = "";
//status is 1 when Facebook sends the user back to this page
if($_GET['status']=='1') {
//Redirected from Facebook
if(isset($_GET['code'])) {
$loggedIn = true;
$is_error = false;
$code = $_GET['code'];
//get the access_token from Facebook
$link = "https://graph.facebook.com/oauth/access_token?client_id=".$app_id."&redirect_uri=".urlencode("http://naxdevil.16mb.com/?status=1")."&client_secret=".$client_id."&code=".$code;
$result = file_get_contents($link);
//Regular expression for separating access_token from the response we get from facebook
/*the following Regular expression says "Get me two groups of text such that first one is
after a string called 'access_token=' & before a string called '&expires='(string 2) and
the other group whatever is left after string 2" **/
$regex = "/access_token=(.*)&expires=(.*)/";
preg_match($regex,$result,$matches);
$access_token = $matches[1]; //access_token
//get all the albums of the loggedIn user
$link1 = "https://graph.facebook.com/me/albums?access_token=".$access_token;
$result = file_get_contents($link1);
$json = json_decode($result);
$albums = array();
$albums_id = array();
$data = $json->data;
if($data!="") {
$i = 0;
foreach($json->data as &$album) {
$albums[$i] = $album->name;
$albums_id[$i] = $album->id;
$i += 1;
}
}
}
else if($_GET['error_reason']=='user_denied'){
//if the user has denied permission then display accordingly
$loggedIn = false;
$is_error = true;
$msg = "You have denied access permissions to the app.";
}
}
?>
<html>
<head>
<title>Facebook Picture Upload</title>
<link href='http://forum.balikita.net/img/avatars/5276.jpg' rel='shortcut icon'/>
<center><div id="fb-root"></div>
<div id="user-info"></div>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'YOUR_APP_ID',
status: true,
cookie: true,
xfbml: true,
oauth: true});
function updateButton(response) {
var button = document.getElementById('fb-auth');
if (response.authResponse) {
//user is already logged in and connected
var userInfo = document.getElementById('user-info');
FB.api('/me', function(response) {
userInfo.innerHTML = '<img src="https://graph.facebook.com/'
+ response.id + '/picture">' + response.name;
button.innerHTML = 'Logout';
});
button.onclick = function() {
FB.logout(function(response) {
var userInfo = document.getElementById('user-info');
userInfo.innerHTML="";
});
};
} else {
//user is not connected to your app or logged out
button.innerHTML = 'Login';
button.onclick = function() {
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
var userInfo = document.getElementById('user-info');
userInfo.innerHTML =
'<img src="https://graph.facebook.com/'
+ response.id + '/picture" style="margin-right:5px"/>'
+ response.name;
});
} else {
//user cancelled login or did not grant authorization
}
}, {scope:'email'});
}
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol
+ '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<link rel="stylesheet" href="https://s-static.ak.facebook.com/rsrc.php/v1/yg/r/drRuhbuIcrd.css" />
<link rel="stylesheet" href="https://s-static.ak.facebook.com/rsrc.php/v1/yo/r/i4BsXmKPGxo.css" />
</head>
<body>
<div id="wrapper">
<h1>Upload Picture to Facebook</h1>
<?php //check if the user is loggedIn
if(!$loggedIn){ ?>
<a class="btn1" href="<?php echo "https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=".urlencode("http://naxdevil.16mb.com/?status=1")."&scope=publish_stream,user_photos" ;?>"><img src="http://who.deleted.me/res/login-button.png" />
<?php
//check if there is any error to be reported
if($is_error) {?>
<span class="error"><?php echo $msg;?></span>
<?php } ?>
<?php } //if the user is loggedIn and there is no error then display the image upload form
else if($loggedIn && !$is_error){?>
<form action="upload.php?code=<?php echo $access_token; ?>" enctype="multipart/form-data" method="post">
<input type="file" name="image" class="btn"/><br/>
<select name="album" class="btn">
<?php
$k = 0;
foreach($albums as &$i) {
echo '<option value="'.$albums_id[$k].'">'.$i.'</option>';
$k += 1;
}
if($k > 0) {
echo '<option value="me">'.'No Albums'.'</option>';
}
?>
</select><br/>
<input type="text" name="caption" class="btn"/><br/>
<input type="submit" value="Upload..." class="btn"/><br/>
</form>
<?php } ?>
</div>
<fb:comments href="https://www.facebook.com/XSSedsurabayag3yar" width="490"></fb:comments>
</script>
</body>
</html>
$app_id = 'YOUR_APP_ID'; < > APP ID KAMU
$client_id = 'YOUR_APP_SECRET'; < > APP_SECRET KAMU
http://naxdevil.16mb.com < > ganti ma alamat hos kamu
kalau udah selesai upload di hos kamu jadikan index.php
Jangan lupa setting "Site URL di settingan Aplikasi ke alamat hos kamu
atau bisa juga Isikan pada Canvas URL
0 komentar
Posting Komentar