I am using graph api provided by Facebook. It is not working as I want it to. I am using this api to import user's photos to my website. But I am not able to import them. Infact I can Import the images from the user account in which I have created the app. But from any other accounts I am not able to import images. My Index file is as below:
index.php
<?php
/***********************************************************************
* Plugin Name: Facebook Plugin
* Plugin URI: http://www.picpixa.com/
* Version: Current Version
* Author: Ashish Shah
* Description: Plugin To Import Images From User's Facebook Account
* as well as post the image of personalized product to
* his/her facebook account
**********************************************************************/
include_once "fbmain.php";
ini_set("display_errors",0);
?>
<script type="text/javascript">
function streamPublish(name, description, hrefTitle, hrefLink, userPrompt) {
FB.ui({method: 'feed',
message: userPrompt,
link: hrefLink,
caption: hrefTitle,
picture: ''
});
//http://developers.facebook.com/docs/reference/dialogs/feed/
}
function publishStream() {
streamPublish("Stream Publish", 'Checkout personalized products at www.picpixa.com. I found some of them are just awesome!', 'Checkout www.picpixa.com', 'http://www.picpixa.com', "Personalized Products");
}
</script>
<style type="text/css">
.box{
margin: 5px;
border: 1px solid #60729b;
padding: 5px;
width: 500px;
height: 200px;
overflow:auto;
background-color: #e6ebf8;
}
</style>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId: '<?= $fbconfig['appid'] ?>',
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
</script>
<?php if (!$user) { ?>
You have to login using Facebook Login Button to see api calling result.
<a href="<?= $loginUrl ?>"><img src="Images/login.png"></a>
<?php }// else { ?>
<!-- <a href="<?//= $logoutUrl ?>"><img src="Images/logout.png"></a> -->
<?php //} ?>
<!-- all time check if user session is valid or not -->
<?php if ($user) { ?>
<form method="post" action="index.php">
<table border="0" cellspacing="3" cellpadding="3">
<!-- Data retrived from user profile are shown here -->
<tr>
<?php
$i=0;
$showBtn=false;
$albums = $facebook->api("/me/albums");
echo "Albums:<pre>";
print_r($albums);
echo "</pre>";
foreach($albums['data'] as $album){
// get all photos for album
$photos = $facebook->api("/{$album['id']}/photos");
echo "Photos<pre>";
print_r($photos);
echo "</pre>";
foreach($photos['data'] as $photo){
if($i%5 == 0)
{
echo "</tr>";
echo "<tr>";
}
?>
<td align="center"><input type="checkbox" id="facebook_<?=$i;?>" name="facebook[]" value="<?php echo $photo['source']?>"></td>
<td><img src="<?php echo $photo['source']?>" width = "150px" height = "150px" /></td>
<?php
$i++;
$showBtn=true;
}
}
if($showBtn){
echo"<tr><td><input type='submit' name='copy' value='Copy Selected Files' ></td></tr>";
}
?>
</tr>
</table>
</form>
<?php }?>
<?php
if(isset($_POST['copy']))
{<My Code After importing Images>}
?>
Can anyone tell me what is the problem?
FYI: I have not submitted my app for the review yet.
Thank you,
Update: There is one update I found. In one user account (In which I have created app) is is asking for user's authorization for public profile as well as for photos. But in another user account it is asking for the user's authorization for only user's public profile.