PHP + Facebook:如何在墙上上传照片? [英] PHP + Facebook: how to upload photo on the wall?

查看:137
本文介绍了PHP + Facebook:如何在墙上上传照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的页面墙上发布消息的通常方式是:

  $ args = array(
'access_token'=> $ page_access_token,
'message'=> $ title,
'link'=> $ link,
'name'=>'这是标题' ,
'description'=>'这是在页面上发布的测试',
//'picture'=>'http://www.example.com/directory/images/ 30.jpg'
);

$ post_id = $ facebook-> api(/ $ pageId / feed,post,$ args);

但是如何将图像发布到我的墙上 - 替代方法:点击上传按钮,选择出一个图像 - >并上传,图像在墙上。



我有一些图像,我想要上传到我的墙上。 p>

提前感谢

解决方案

https://developers.facebook.com/blog/post/498/ 此链接可以帮助您...



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



1 - 当前用户的默认应用程序相册
这个例子将上传照片到您当前用户的默认应用程序专辑。如果专辑不存在,它将被创建。



$ facebook-> setFileUploadSupport(true);
$ args = array('message'=>'照片说明');
$ args ['image'] ='@'。 realpath($ FILE_PATH);



$ data = $ facebook-> api('/ me / photos' ,'post',$ args);
print_r($ data);
2 - 目标专辑'
此示例将照片上传到特定的相册。



$ facebook-> setFileUploadSupport(true);
$ args = array('message'=>'照片说明');
$ args ['image'] ='@'。 realpath($ FILE_PATH);



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


The usual way as I post messages to my page wall is like:

        $args = array(
            'access_token'  => $page_access_token,
            'message'       => $title,
            'link'          => $link,
            'name'          => 'This is title',
            'description'   => 'This is a testing of the posting on page',
            //'picture'     => 'http://www.example.com/directory/images/30.jpg'
        );

        $post_id = $facebook->api("/$pageId/feed","post",$args);

But how can I post an images to my wall - the alternative to: click to UPLOAD button, pick out an image -> and upload, image is on to wall.

I have on my FTP some images and these ones I would like to upload to my wall.

Thanks in advance

解决方案

https://developers.facebook.com/blog/post/498/ this link can help you...

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.

1 - Default Application Album of 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.

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

$data = $facebook->api('/me/photos', 'post', $args); print_r($data); 2 - Target Album` This example will upload the photo to a specific album.

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

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

这篇关于PHP + Facebook:如何在墙上上传照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆