【发布时间】:2012-03-22 07:36:45
【问题描述】:
例如,我在我的网站上安装了 WordPress。我想通过 URL 上传 Facebook 上的图片。我的图片网址是:
http://example.com/wp-content/abc123.jpg
现在,我想通过我自己的网站在 Facebook 上将这张图片直接上传到特定相册中。我完全是N00b!所以对编码一无所知..
我的目标是创建一个封面网站。
*第二次更新 *: 这是我现在使用的代码:
<?php
$app_id = "12354";
$app_secret = "1213243434";
$post_login_url = "http://example.com/sdsds";
$album_id = "1234224";
$photo_url = "http://example.coom/test.jpg";
$photo_caption = "my caption";
$code = $_REQUEST["code"];
//Obtain the access_token with publish_stream permission
if (!$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
. "&client_secret=" . $app_secret
. "&redirect_uri=" . urlencode( $post_login_url)
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
// POST to Graph API endpoint to upload photos
$graph_url= "https://graph.facebook.com/"
. $album_id . "/photos?"
. "url=" . urlencode($photo_url)
. "&message=" . urlencode($photo_caption)
. "&method=POST"
. "&access_token=" .$access_token;
echo '<html><body>';
echo file_get_contents($graph_url);
echo '</body></html>';
}
?>
所以从这段代码中我可以将“test.jpg”上传到 facebook 但现在的问题是我不想只上传一张图片,我想上传很多图片所以我不想改变"$photo_url = "http://example.coom/test.jpg";"新照片的此代码任何帮助将不胜感激!
【问题讨论】:
-
这更像是一个帮助站点,而不是“我们只会给你代码”的站点。我建议你看看developers.facebook.com 网站,特别是developers.facebook.com/docs/reference/api/photo
-
最重要的是,这个帖子developers.facebook.com/blog/post/526应该有关于通过url上传的信息