Solved

Facebook - PHP - Post to fan page wall as fan page

Posted on 2011-09-10
1
766 Views
Last Modified: 2012-05-12
Hi all,

This is my problem, and any help is greatly appreciated.

I have a website, with a database in which I have successfully stored the facebook user id, access token and fan page id (by using the normal api to get permission etc etc).

Now, the problem is that i would like to be able to post a message to the fan page, which I can do, however the message appears under the name of the user's personal facebook account.  For example if I create a fan page called 'My Company' and post a message to it using my code the message appears as if from 'Matt Jellings'.  However, if I go to the facebook fan page in facebook and post a message it appears as though it's from My Company.

What I need to do is find a way to do this in PHP so that message that are posted from my script appear as if from that company rather than the personal user.

I hope some of that makes sense, here's my code

	$facebook = new Facebook(array(
	  'appId'  => $app_id,
	  'secret' => $app_secret,
	));
		$publishStream = $facebook->api("/" . 'fan_page_id_here' . "/feed", 'post', array(
			'message' => 'Test message here',
			'access_token'=> 'facebook_access_token_here'
			)
		);

Open in new window


I should also add that the messages posted from my app need to appear in the news stream (or whatever its called) for people who have liked this fan page.

As always any help is appreciated

Thanks,

Matt
0
Comment
Question by:MattJellings
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
MattJellings earned 0 total points
ID: 36516884
for anyone else trying to do the same as me, here's the answer that I've found to work..

presuming your app has appropriate permissions (publish_stream I believe and probably offline_access)

		$fbres = $facebook->api(array(
			'access_token' => 'access_token_here', 
			'method' => 'stream.publish', 
			'message' => 'message_body_here', 
			'uid' => 'facebook_fan_page_id_here'
		));

Open in new window

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question