0
벨로우즈 코드는 정상적으로 작동합니다. 사진을 업로드하고 새 사진을 만듭니다. 분명히 어딘가에 리다이렉트하는 법을 알지 못하고 앨범 ID가있는 빈 페이지로 끝납니다. 나는 리다이렉트 링크를 만들고 그 리디렉션 링크에 사진을 보여주고 싶다. 사진이 업로드 된 후 사용자가 리디렉션되기를 원합니다. 사용자가 업로드 버튼을 누르면 사진이 업로드됩니다.Facebook에 사진을 업로드하고 앨범을 만듭니다. 다운로드 후 사진이 표시된 다른 페이지로 사용자를 리디렉션
$post_login_url = "http://apps.facebook.com/firstestt/upload.processor.php";
$album_name = 'Facepic Album';
$album_description = 'http://apps.facebook.com/firstestt/';
$code = $_REQUEST["code"];
$facebook->setFileUploadSupport(true);
//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 = $facebook->getAccessToken();
// 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/>';
//When this button is pressed the page should upload the photo and redirect the user to another link
echo '<input type="submit" value="Upload" /><br/>';
echo '</form>';
echo '</body></html>';
}
위의 코드에서 어느 시점에 리디렉션하고 싶습니까? 위의 코드 스 니펫에 설명을 추가하여 알려주십시오. – DMCS
나는 그 감사를했다! –