1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Facebook app can't upload all pictures to users album.

Discussion in 'FaceBook' started by mojstermiha, Dec 9, 2012.

  1. mojstermiha

    mojstermiha Regular Member

    Joined:
    Jul 27, 2010
    Messages:
    447
    Likes Received:
    1,061
    Last 2 days, we can't figure out how to solve this problem. We have an app where user creates or modifies his own pictures or upload new pictures into the app and then we have the option to upload those pictures to his own album.


    For some reason it works selectively. It uploads some, but never all, in some cases it won't upload pictures that were not on Facebook before, but even that is not consistent over all test accounts. The script should work fine because we always get the final picture URL, the problem is only in uploading via app to Facebook.


    Conclusion was that this is some kind of spam protection but it seems so strict, too strict. Could be permission issue or it is FB bug. Any ideas? Thanks
     
  2. indianbill007

    indianbill007 Jr. VIP Jr. VIP

    Joined:
    Jan 8, 2010
    Messages:
    4,813
    Likes Received:
    4,051
    Occupation:
    Making Money when the world is sleeping
    Location:
    Menlo Park - Next to Zuck
    Post the code so someone can look at it and help you debug, the question is very vague as of now. There can be multiple situations which might lead to the pics not getting uploaded.
     
  3. mojstermiha

    mojstermiha Regular Member

    Joined:
    Jul 27, 2010
    Messages:
    447
    Likes Received:
    1,061
    Alright, I'll tell developer to send me the part of code that do the upload. I guess this is where the problem must be. Thanks Bill
     
  4. mojstermiha

    mojstermiha Regular Member

    Joined:
    Jul 27, 2010
    Messages:
    447
    Likes Received:
    1,061
    Here is developers reply:

    We have a very weird and annoying problem with Facebook PHP SDK api and photo upload.
    Currently, we receive base64 image from POST http request, convert it to .png image in cache folder and then use standard facebook api for uploading an image.
    Now, problem is, that sometimes image is uploaded, and sometimes nothing gets uploaded. And facebook doesn't return any error message.
    We have checked, when image doesn't upload to Facebook, it's still generated on server. So It cannot be server problem
    or maybe that our image is not saved correctly. Image is always on server, but Facebook api doesn't post image.


    Code:

    Code:
     $this->facebook->setFileUploadSupport(true);                    
                        
                                // requires php5
                        define('UPLOAD_DIR', 'cache/');
                        $img = $image;
                        $img = str_replace('data:image/png;base64,', '', $img);
                        $img = str_replace(' ', '+', $img);
                        $data = base64_decode($img);
                        $filenamer = $this->generateRandomString();
                        $file = UPLOAD_DIR . $filenamer . '.png';
                        $success = file_put_contents($file, $data);
                        
                        
                        $finalURL =  '@cache/'.$filenamer.'.png';
    
    
                        echo "
                        <h3><strong>Your photo was successfully posted to your wall!</strong></h3>                    
                        ";
    
    
                       /// Let's upload photo to user's wall
                       $this->facebook->api('/me/photos', 'POST', array(
                                            'source' => $finalURL ,
                                            'message' => $sporocilo,
                                            ));
    
     
  5. indianbill007

    indianbill007 Jr. VIP Jr. VIP

    Joined:
    Jan 8, 2010
    Messages:
    4,813
    Likes Received:
    4,051
    Occupation:
    Making Money when the world is sleeping
    Location:
    Menlo Park - Next to Zuck
    convert it to .png image in cache folder => This is where the problem can be, sometimes the images don't get created successfully.

    Add this code -


    if(filesize($finalURL)>0)
    {
    //code for fb posting
    }
    else
    {
    //error handling code
    }

     
    • Thanks Thanks x 1
  6. boommedia

    boommedia Registered Member

    Joined:
    Feb 2, 2012
    Messages:
    99
    Likes Received:
    10
    also make sure you update the php sdk code. they changed things a few days ago and did a fix with a new sdk
     
    • Thanks Thanks x 1
  7. mojstermiha

    mojstermiha Regular Member

    Joined:
    Jul 27, 2010
    Messages:
    447
    Likes Received:
    1,061
    Thanks guys. I'll forward this info to developer and hopefully, he'll be able to fix it.

    Btw, Bill, do you still offer VA for FB app development?
     
  8. indianbill007

    indianbill007 Jr. VIP Jr. VIP

    Joined:
    Jan 8, 2010
    Messages:
    4,813
    Likes Received:
    4,051
    Occupation:
    Making Money when the world is sleeping
    Location:
    Menlo Park - Next to Zuck
  9. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    My scripts stopped working in november with old version of php sdk. Had to adapt their new version.