Home > Article > Backend Development > How Can I Post to My Facebook Fan Page using the PHP SDK?
Posting to Facebook Fan Pages with PHP
Publishing content directly to Facebook fan pages without an RSS feed can be a challenge. To address this, here's a detailed guide to help you seamlessly post to your fan page using the PHP SDK.
Step 1: Permissions and Page Token
Step 2: Posting to the Page Wall
Example Code:
<?php $page_access_token = 'XXXXXXXX'; $page_id = 'YYYYYYYY'; $data['picture'] = "http://www.example.com/image.jpg"; $data['link'] = "http://www.example.com/"; $data['message'] = "Your message"; $data['access_token'] = $page_access_token; $post_url = 'https://graph.facebook.com/' . $page_id . '/feed'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $post_url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $return = curl_exec($ch); curl_close($ch); ?>
By following these steps, you can effectively post content to your Facebook fan page using the PHP SDK, enabling you to engage with your audience effortlessly.
The above is the detailed content of How Can I Post to My Facebook Fan Page using the PHP SDK?. For more information, please follow other related articles on the PHP Chinese website!