0

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.

Ashish Shah
  • 152
  • 1
  • 3
  • 16
  • hmmm that code looks old tom me. "I haven't submitted my app for review yet" means you already had one but has not been reviewed for the breaking changes, or that the app is new? These would be different problems (if the app is new, you need review from Facebook for basically anything except the standard authorizations) – tattvamasi Jun 19 '14 at 12:26
  • 1
    @tattvamasi My app is new. But If you are right then it should not be working for my one id (in which i have created the app) but it works. It is importing photos from that user account. And there is one update please see my updated question... – Ashish Shah Jun 19 '14 at 12:36
  • okay, I'm ready to post my asnwer :) Thanks, your update was very useful – tattvamasi Jun 19 '14 at 13:11

1 Answers1

1

if your application, as you say, is new, you need to undergo the Facebook review first. The fact that the user permissions the apps asks you (the developer) are different than those the app asks other users, means that those permissions are only available to you, for testing. Once you test each action, and submit it for review, and the action is approved, that action will be available to other users.

In order to submit the action for review, you need to test that action on your account. If the application doesn't even let you, the developer, test the action you want to implement for every user, then it won't be possible for the Facebook staff to review your application, and the actions (and permissions) it requires to work.

Todo this, visit https://developers.facebook.com, click on Apps, select your app, click on "Status & Review" (on the left), sroll down the page, click on "Submit items for approval", submit the permission required to get the photos of a user, explain why your app needs it, how it uses it, provide examples and screen shots.

If approved, that feature will be live for your app, and available not only to you, but to anyone. These changes went live on April 30th 2014. You can read more here, especially where it says

In order for your app to access additional elements of a person's Facebook profile (read permissions) or to publish content to Facebook on their behalf (write permissions), you will need to submit for review

I hope this help.

tattvamasi
  • 845
  • 1
  • 7
  • 14
  • thanx for the answer... It is really helpfull... Thank you very much :) I have same problem with the google php sdk... can you solve that? – Ashish Shah Jun 19 '14 at 14:02
  • Link to my question about google problem (Similar): http://stackoverflow.com/questions/24308664/google-api-is-not-working-properly – Ashish Shah Jun 19 '14 at 14:09
  • 1
    glad I was helpful! And by the way, you even need to get like actions (like via app) approved now (just realized, LOL). I'll check Google too, see if I can help. – tattvamasi Jun 19 '14 at 14:15
  • hello @tattvamasi, I am facing a problem. Please visit below question: http://stackoverflow.com/questions/24762287/facebook-graph-api-logout-url-is-not-working I have posted it many days ago but haven't got any response. Can you please help me to solve this? – Ashish Shah Jul 22 '14 at 14:13
  • Hello tattvamasi, I am facing a problem while importing photos from user timeline. If user have uploaded multiple images, then those images are not being imported in my website. Otherwise all is working as expected. Can you please help me with this? – Ashish Shah Aug 11 '14 at 06:49
  • Hi @AshishShah I think you have to start a new question for that, otherwise people get here and dont' udenrstand what we're talking about – tattvamasi Aug 23 '14 at 16:04
  • #tattvamasi. No need to do that now as I came to know that it is the bug in the Open Graph only. I had a conversation with one of the developers at facebook and they told me that they are checking it internally. – Ashish Shah Aug 25 '14 at 06:04