API将照片上传到相册

API将照片上传到相册

本文介绍了如何使用Facebook Graph API将照片上传到相册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是代码:

$file= 'bbbb.jpg';
$data = array(
            basename($file) => "@".realpath($file),
            "caption" => "Uploaded using graph api",
            "aid" => '13595',
            "access_token" => $accessToken,
            'method' => 'photos.upload'
);
$sds =$facebook->api($data);

这是错误

该怎么办?

推荐答案

以下是使用Graph API上传照片的各种方法。这些例子假设你已经实例化了$ facebook对象,并为当前用户提供了一个有效的会话。

Here are some various ways to upload photos using the Graph API. The examples assume you've instantiated the $facebook object and have a valid session for the current user.

此示例将照片上传到当前用户的默认应用程序专辑。如果专辑不存在,它将被创建。

This example will upload the photo to your default application album of the current user. If the album does not yet exist it will be created.

$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/me/photos', 'post', $args);
print_r($data);



2 - 目标相册



将照片上传到特定的专辑。

2 - Target Album

This example will upload the photo to a specific album.

$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/'. $ALBUM_ID . '/photos', 'post', $args);
print_r($data);



3 - 具有访问令牌的目标相册



3 - Target Album with Access Token

This example will upload a photo to a specific album which requires an access token.

 $args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/'. $ALBUM_ID . '/photos?access_token='. $ACCESS_TOKEN, 'post', $args);
print_r($data);

这篇关于如何使用Facebook Graph API将照片上传到相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:02