【发布时间】:2014-06-19 21:23:50
【问题描述】:
我正在使用 Facebook 提供的图形 API。它没有按我的意愿工作。我正在使用这个 api 将用户的照片导入我的网站。但我无法导入它们。事实上,我可以从创建应用程序的用户帐户导入图像。但是从任何其他帐户我都无法导入图像。 我的索引文件如下:
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>}
?>
谁能告诉我是什么问题?
仅供参考:我尚未提交我的应用以供审核。
谢谢,
更新:我发现了一个更新。在一个用户帐户(我在其中创建了应用程序)中,要求用户对公共个人资料和照片进行授权。但在另一个用户帐户中,它只要求用户对用户的公开个人资料进行授权。
【问题讨论】:
-
嗯,我的代码看起来很老。 “我还没有提交我的应用程序以供审核”是指您已经拥有一个但尚未针对重大更改进行审核,或者该应用程序是新的?这些将是不同的问题(如果应用程序是新的,您需要从 Facebook 审核除标准授权之外的任何内容)
-
@tattvamasi 我的应用是新的。但如果你是对的,那么它不应该适用于我的一个 id(我在其中创建了应用程序),但它可以工作。它正在从该用户帐户导入照片。还有一个更新,请查看我更新的问题...
-
好的,我已经准备好发布我的答案了 :) 谢谢,您的更新非常有用
标签: php facebook facebook-graph-api