开发者

Publish image on facebook user's wall with php

开发者 https://www.devze.com 2023-03-06 04:53 出处:网络
Is there a way to send image to a facebook user\'s wall? To publish texts I use this code: $arpost = array(

Is there a way to send image to a facebook user's wall? To publish texts I use this code:

$arpost = array(
            'message' => $text,
            'access_token' => $token
        );

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arpost));
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        $result = curl_exec($ch);

        curl_close($ch);

For future generations: http://developers.facebook.com/docs/reference/api/p开发者_运维知识库ost/ <- param is called picture, so you do it like this:

$args = array(
        'message' => $text,
        'picture' => $link2picture
    );

    $this->_facebook->api('/me/feed/', 'post', $args);


Here is a link to doing it in Java... perhaps you can use it for some ideas.

Android - Upload photo to Facebook with Facebook Android SDK

Check the facebook php sdk too. It should be there.

https://github.com/facebook/php-sdk/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号