Posting to a Facebook Fan Page with PHP: A Comprehensive Guide
Introduction:
Posting content directly to a Facebook fan page has become a common practice for businesses and organizations. However, finding up-to-date and reliable resources can be a challenge. This article aims to address this issue by providing a comprehensive guide to posting to fan pages via PHP.
Step 1: Obtain Permissions and Page Token
Step 2: Posting to Page Wall via PHP
$page_access_token = 'XXXXXXX'; $page_id = 'YYYYYYYY';
$data['picture'] = "http://www.example.com/image.jpg"; $data['link'] = "http://www.example.com/"; $data['message'] = "Your message"; $data['caption'] = "Caption"; $data['description'] = "Description";
$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);
The above is the detailed content of How can I post content to my Facebook Fan Page using PHP?. For more information, please follow other related articles on the PHP Chinese website!