Jump to content
Fórum Script Brasil
  • 0

Me Ajude- Coisa Simples -


Werner Pacheco
 Share

Question

Galera eu sou muito leigo e novato no assunto de PHP!

e peço a colaboração de vocês da Script Brasil para me tirar uma duvida muito simples:

Este codigo é pra postar uma imagem no album do facebook da pessoa, porem eu não quero que ela faça upload da imagem... eu quero que o codigo pegue uma imagem do servidore use ela para postar no album!

echo '<html><body>';

echo '<form enctype="multipart/form-data" action="'

.$graph_url. ' "method="POST">';

echo 'Please choose a photo: ';

echo '<input name="source" type="file"><br/><br/>';

echo 'Say something about this photo: ';

echo '<input name="message" type="hidden"

value="Descrição Da Imagem"><br/><br/>';

echo '<input type="submit" value="Upload" /><br/>';

echo '</form>';

echo '</body></html>';

alguém Me ajuda? eu já estou 3 dias tentando arrumar isso e não consigo!

só quero que ao invés do codigo usar o arquivo de upload ele pegue um arquivo do servidor /img/namefile.jpg

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
<?php

$app_id = "IDDOMEUAPLICATIVO";

$app_secret = "SECRETKEYAPP";

$post_login_url = "https://localhost/facebookresearch/photoupload.php";

$album_name = 'PHP Test Album';

$album_description = 'YOUR_ALBUM_DESCRIPTION';

$code = $_REQUEST["code"];

//Obtain the access_token with publish_stream permission

if(empty($code))

{

$dialog_url= "http://www.facebook.com/dialog/oauth?"

. "client_id= . $app_id

. "&redirect_uri=" . urlencode($post_login_url)

. "&scope=publish_stream";

echo("<script>top.location.href='" . $dialog_url .

"'</script>");

}

else {

$token_url= "https://graph.facebook.com/oauth/"

. "access_token?"

. "client_id=" . $app_id

. "&redirect_uri=" . urlencode( $post_login_url)

. "&client_secret=" . $app_secret

. "&code=" . $code;

$response = file_get_contents($token_url);

$params = null;

parse_str($response, $params);

$access_token = $params['access_token];

// Create a new album

$graph_url = "https://graph.facebook.com/me/albums?"

. "access_token=". $access_token;

$postdata = http_build_query(

array(

'name' => $album_name,

'message' => $album_description

)

);

$opts = array('http' =>

array(

'method'=> 'POST',

'header'=>

'Content-type: application/x-www-form-urlencoded',

'content' => $postdata

)

);

$context = stream_context_create($opts);

$result = json_decode(file_get_contents($graph_url, false,

$context));

// Get the new album ID

$album_id = $result->id;

//Show photo upload form and post to the Graph URL

$graph_url = "https://graph.facebook.com/". $album_id

. "/photos?access_token=" . $access_token;

echo '<html><body>';

echo '<form enctype="multipart/form-data" action="'

.$graph_url. ' "method="POST">';

echo 'Adding photo to album: ' . $album_name .'<br/><br/>';

echo 'Please choose a photo: ';

echo '<input name="source" type="file"><br/><br/>';

echo 'Say something about this photo: ';

echo '<input name="message" type="text"

value=""><br/><br/>';

echo '<input type="submit" value="Upload" /><br/>';

echo '</form>';

echo '</body></html>';

}

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.8k
    • Total Posts
      648.8k
×
×
  • Create New...