Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法将照片上载到facebook_Php_Facebook Graph Api_Upload_Photo - Fatal编程技术网

Php 无法将照片上载到facebook

Php 无法将照片上载到facebook,php,facebook-graph-api,upload,photo,Php,Facebook Graph Api,Upload,Photo,我正在尝试创建一个PHP页面,它将创建一个相册并上传一张照片。到目前为止,它验证并创建相册没有任何问题,但我似乎无法让它上传照片。我不断得到以下错误: 警告:福朋(https://graph.facebook.com/yyyyyyyyyyyyyyyyy/photos?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

我正在尝试创建一个PHP页面,它将创建一个相册并上传一张照片。到目前为止,它验证并创建相册没有任何问题,但我似乎无法让它上传照片。我不断得到以下错误:

警告:福朋(https://graph.facebook.com/yyyyyyyyyyyyyyyyy/photos?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)[function.fopen]:无法打开流:HTTP请求失败!HTTP/1.0 400第96行/home/content/30/8734730/html/uploadPhoto.php中的错误请求


照片上传

好吧,我有一个愚蠢的问题。。。我在GoDaddy上托管我的PHP页面,并试图从运行Internet Explorer的PC上传一张照片。调试过程中,似乎对照片的位置存在一些困惑,因此我的问题是,如何指定要将视频从本地PC上传到FB?
<html>
<head>
<title>Photo Upload</title>
</head>
<body>
<?php

$app_id = "xxxxxxxxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$post_login_url = "http://xyz.com/uploadPhoto.php";

$album_name = "Brand Image Productions";
$album_description = "Blah Blah event Photos";

$photo_source = 'C:\Users\Public\Pictures\Sample Pictures\Lighthouse.jpg';
$photo_message = 'Here is the lighthouse';

$code = $_REQUEST["code"];
echo "code ==>" . $code . '<br/><br/>';

//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,user_photos";
    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'];
    echo "access_token ==>" . $access_token . '<br/><br/>';

    // 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;    //upload photo
    echo "album_id ==>" . $album_id . '<br/><br/>';


    // Upload the photo

    $graph_url = "https://graph.facebook.com/" . $album_id . "/photos?access_token=" . $access_token;

    echo "graph_url ==>" . $graph_url . '<br/><br/>';
    echo "photo_message ==>" . $photo_message . '<br/>';
    echo "photo_source  ==>" . $photo_source . '<br/><br/>';

    $postdata = http_build_query(
        array(
            'message' => $photo_message,
            'source' => $photo_source
        )
    );

    $opts = array('http' =>
        array(
            'method'=> 'POST',
            'header'=> 'Content-type: application/x-www-form-urlencoded',
            'enctype' => 'multipart/form-data',
            'content' => $postdata
        )
    );

    $context  = stream_context_create($opts);
    $fp = fopen($graph_url, 'r', false, $context);
    fpassthru($fp);
    fclose($fp);

}
?>
</body>
</html>