简体   繁体   中英

how to build a batch job to post a wall-to-wall facebook post using php

I have written a facebook app. I want to write a batch job using php to post a wall-to-wall post to user A and his friend B (B is not the app user) such that the post is a wall-to-wall post as user A-> B.

I have tried the graph feed api but can only post to user A wall and say I have no right to post to B's wall. In fact I found some apps have done similar things and i guess it is a batch job (as the post is released when I am not using the app).

As it is a batch job, i dont have user's access_token. Is it possible to do it?

When the user authenticates your app, you would need to request offline_access extended permission to be able to access their account from a batch job (the normal access tokens are only valid for 2 hours). You would also need publish_stream extended permission to write on your friends wall.

Try This

Note: $fd is the friend's userID which is an integer number.


$fresult = $facebook->api(
            '/'.$fd.'/feed/',
            'post',
            array('access_token' => $facebook->access_token, 'message' => 'Have a free lunch! :)','link'=> 'https://apps.facebook.com/something,
            'picture'=> 'http://fbrell.com/f8.jpg',
            'name'=> 'Click here to get discount voucher ',
          'caption'=> 'Come and enjoy your meal',
          'description'=> 'Invite your friends to our App using your unique link and win discount vouchers and many more prizes.'

            )
        );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM