Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:56:10+00:00 2026-06-18T08:56:10+00:00

What I am trying to do is: Get person profile pic; Get a randon

  • 0

What I am trying to do is:

  • Get person profile pic;
  • Get a randon pic that is set with de switch
  • And mix the random pic with the person profile pic
  • And show it to the guy!

Can do this?

require_once("src/facebook.php");

$configurar = array();
$configurar['appId'] = '2033xxxxx389';
$configurar['secret'] = 'cc3xxxx9b1';
$configurar['fileUpload'] = true;

$facebook = new Facebook($configurar);

$signed_request = $facebook->getSignedRequest();
$__idPagina = $signed_request["page"]["id"];
$__adminPagina = $signed_request["page"]["admin"];
$__statusLike = $signed_request["page"]["liked"];
$__pais = $signed_request["user"]["country"];
$__locale = $signed_request["user"]["locale"];

$_idUsuario = $facebook->getUser();
?>
<html>
    <head></head>
    <body>

        <?
            if($_idUsuario)
            {
                try
                {
                    if($__statusLike)
                    {
                        //AQUI VAI A PARTE QUE FUNCIONA A MÁGICA DA FOTO! POORRA
                        // DEFINIR VARIAVEIS
                        $foto_x = $_idUsuario."_x.jpg";
                        $foto_y = $_idUsuario."_y.jpg";
                        $img = $_idUsuario.".jpg";

                        copy('http://graph.facebook.com/'.$_idUsuario.'/picture?width=150&height=150', 'lixeira/'.$foto_x);

                        //ARMA ALEATÓRIA NA BAGAÇA
                        $armaRandomica = rand(1,10);

                        //DEFINE O MOLDE DE ACORDO COMO O NUMERO QUE PEGOU AI /\

                        switch ($armaRandomica) {
                            case 1:
                                $moldeArma = "molde/_bazuka.jpg";
                                break;
                            case 2:
                                $moldeArma = "molde/_espada.jpg";
                                break;
                            case 3:
                                $moldeArma = "molde/_espingarda.jpg";
                                break;
                            case 4:
                                $moldeArma = "molde/_faca.jpg";
                                break;
                            case 5:
                                $moldeArma = "molde/_granada.jpg";
                                break;
                            case 6:
                                $moldeArma = "molde/_metralhadora.jpg";
                                break;
                            case 7:
                                $moldeArma = "molde/_nokia.jpg";
                                break;
                            case 8:
                                $moldeArma = "molde/_pistola.jpg";
                                break;
                            case 9:
                                $moldeArma = "molde/_shotgun.jpg";
                                break;
                            case 10:
                                $moldeArma = "molde/_sniper.jpg";
                                break;
                            }

                        echo '<img src="'.$moldeArma.'" />';

                        //JUNTAR A FOTO DO PERFIL COM O MOLDE!

                        header("Content-type:image/jpeg");

                        $stamp = imagecreatefromjpeg($foto_x);
                        $im = imagecreatefromjpeg($moldeArma);
                        $marge_right = 20;
                        $marge_bottom = 330;
                        $sx = imagesx($stamp);
                        $sy = imagesy($stamp);
                        imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
                        imagejpeg($im, $foto_y,100);
                        imagedestroy($im);                      
                        exit;

                        //USA ISSO COMO $perfilUsuario['name'] e talz!
                        $perfilUsuario = $facebook->api('/me','GET');

                        //MOSTRA A FOTO PRO NEGRO!
                        echo '<img src="lixeira/'.$foto_x.'" />';
                    }
                    else
                    {
                        echo '<center><img src="imagens/curta.png"/></center>';
                    }
                }
                catch(FacebookApiException $e)
                {
                    $urlLogin = $facebook->getLoginUrl();
                    echo 'Porfavor <a href="'.$urlLogin.'">LOGUE!</a>';
                    error_log($e->getType());
                    error_log($e->getMessage());
                }
            }
            else
            {
                $urlLogin = $facebook->getLoginUrl();
                echo 'Porfavor <a href="'.$urlLogin.'">LOGUE!</a>';
            }
        ?>
    </body>
</html>

And this is what I get from that code, what should I do to fix this error?

https://i.stack.imgur.com/lrFKd.png

Help me people =D

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:56:11+00:00Added an answer on June 18, 2026 at 8:56 am

    There are two problems with your code:

    1. On line 81, you’re outputting a content-type header. A single file can only output 1 content-type it’s either a HTML file or an Image file. More on this later

    2. On line 83, you’re trying to load an image from Facebook (imagecreatefromjpeg($foto_x);), which cannot be loaded. You’re only specifying the name of the image here (1100000000_x.jpg), without a directory or location, so PHP assumes is a local file and is trying to load a file that is in the same directory as the PHP script. I’m no familiar with the Facebook API, but I suspect that the image should be downloaded from their server, via HTTP, depending on your server settings this might or might not be allowed;

      $stamp = imagecreatefromjpeg(‘http://facebook.com/path/to/image/’ . $foto_x);

    Back to the first issue; It is not possible to output both an image AND the HTML in a single PHP script. One option might be to load the image from Facebook, manipulate it, write it to a file and use that as ‘src’ for the IMG-tag, for example:

    imagejpeg($im, $foto_y,100, '/full/path/to/mynewfilename.jpg');
    

    However, this will probably fill-up your server fast

    Another option is to split your script in two separate files;

    1) A file that outputs the HTML

    2) A file that generates the image

    This page will output the HTML and contains a IMG-tag that points to your image-generating .php page

    <!DOCTYPE HTML>
    <html>
        <head>.....</head>
        <body>
            <img src='./my_super_image.php' /><!-- <<<< The name of your image script -->
        </body>
    </html>
    

    This page will generate and output an image (only an image, nothing else)!:

    <?php
    require_once("src/facebook.php");
    
    .....
    
    header("Content-type:image/jpeg");
    
    $stamp = imagecreatefromjpeg('http://facebook.com/path/to/' . $foto_x);
    $im = imagecreatefromjpeg($moldeArma);
    $marge_right = 20;
    $marge_bottom = 330;
    $sx = imagesx($stamp);
    $sy = imagesy($stamp);
    imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
    imagejpeg($im, $foto_y,100);
    imagedestroy($im);                      
    ?>
    

    The code above is just for illustration, nothing has been tested!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get this expression to work, can someone look at it and tell
I'm trying to get a property from an array of object that can be
I'm trying to get databinding set up in WPF. I've got the class person,
I am trying to get the teams a person belongs to using this query.
I've been trying to get a window to show up asking the person to
Trying to get the following to work but can't really find what's wrong that
Trying to get a random string out of ListArray on the button pressed. Always
I'm trying to get names of person with at least birthday 1950. SELECT Person.names...
I am trying to get a better idea on this as so far I
I am trying to get a ; demlimited string of all the relatives that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.