Automatically posting to a user's (my) stream

1 view
Skip to first unread message

Ted K

unread,
Aug 10, 2009, 9:18:06 PM8/10/09
to facebooker
Background: I am rolling a custom blog with the ability to update my
status. I can post a new status to my blog but I would also like to
automatically update my Twitter and Facebook accounts. Twitter is
done, but I'm having difficulty getting it to work with Facebook.

I'm running Facebooker with authlogic_facebook authentication through
authlogic. I have implemented Facebook Connect authentication and
everything is running fine. I can also create the following link:

<%= link_to_function "Publish to your stream",
"FB.Connect.streamPublish('This is a status update', null, null, null,
null, null, true);" %>

And it will automatically update my Facebook status to "This is a
status update" in the background. But what I would like to do is have
this happen automatically after I create a Status object. (after
create is executed in my statuses controller)

I have tried everything I can think of, including trying to mirror the
fb_user_action syle, but have only been able to get
FB.Connect.streamPublish to work through the aforementioned
link_to_function.

Has anyone implemented a similar thing? Or have any suggestions?
Thanks a bunch,

Ted

Shayan Guha

unread,
Aug 11, 2009, 3:02:38 AM8/11/09
to faceb...@googlegroups.com
Are you using this function
http://facebooker.rubyforge.org/classes/Facebooker/User.html#M000417?

What happens when you try to publish in your after create? Any log output?

Ted K

unread,
Aug 11, 2009, 5:05:34 PM8/11/09
to facebooker
Thanks for the response, I get an "undefined method `publish_to'"
error. I assume this is because I haven't instantiated a
Facebooker::User or something similar.

All I have done so far is setup authlogic and
authlogic_facebook_connect to handle authentication (http://github.com/
kalasjocke/authlogic_facebook_connect/tree/master).
authlogic_facebook_connect requires Facebooker, which I have installed
and required. I am able to implement Facebook Connect successfully
and have full access to all of FBML. I can also use the
aforementioned link_to_function to implement FBJS successfully.

Can you suggest a best practice for instantiating a new
Facebooker::User (or similar) that would allow me to call
"publish_to"?

I have a FacebookUser model which stores the user's facebook id in the
model.

Thanks again,

Ted

On Aug 11, 2:02 am, Shayan Guha <shayang...@gmail.com> wrote:
> Are you using this functionhttp://facebooker.rubyforge.org/classes/Facebooker/User.html#M000417?

Pavel Obod

unread,
Aug 12, 2009, 5:54:00 AM8/12/09
to facebooker
Hi. There is my code. Make it clear you need to create new session to
publish.

user_uid = 12345678
session_new = Facebooker::Session.create
@userFB = Facebooker::User.new(user_uid , session_new)
begin
@userFB.publish_to(@userFB,
:message => "has recieved 10 tokens for
inviting friend",
:action_links => [{
:text => 'See my results',
:href => "http://apps.facebook.com/
myapp"},
{
:text => 'Try to beat him',
:href => "http://waker.com"}
],
:attachment => {
:name => "The rank of this user is
increasing",
:href => 'http://waker.com',
:caption => 'Waker is a multiplayer
card game website for the Arab world. Register now and start playing
one of our online card games for FREE!',
:description => 'Start your first game
right now',
:media => [
{
:type => 'image',
:src => "http://waker.com/
images/hp_mascot_ar-trans.png",
:href => "http://waker.com"}

]})

If u have any questions please write here and remind me about it
trough e-mail.
Cheers!

Ted K

unread,
Aug 12, 2009, 5:18:23 PM8/12/09
to facebooker
Thanks for the reply,

I tried the following code:

@facebook_session = Facebooker::Session.create
@facebook_user = Facebooker::User.new
(current_facebook_user.facebook_uid, @facebook_session)
@facebook_user.publish_to(@facebook_user, :message => "this is
a test for my wall")

When run, I get a:

Facebooker::Session::MissingOrInvalidParameter in
StatusesController#create
Invalid Parameter

I've tried putting all sorts of parameters in, but it always results
in a Invalid Parameter error. I tried searching for the error, but
couldn't find anything that relates to my question. In my console, I
can do the following:

>> session = Facebooker::Session.create

=> #<Facebooker::Session:0x2280f1c @batch_request=nil, @expires=nil,
@auth_token=nil, @secret_key="MY_SECRET_KEY", @uid=nil,
@api_key="MY_API_KEY", @session_key=nil, @secret_from_session=nil>

>> user = Facebooker::User.new(19400903, session)

=> #<Facebooker::User:0x227da24 @session=#<Facebooker::Session:
0x2280f1c @batch_request=nil, @expires=nil, @auth_token=nil,
@secret_key="MY_SECRET_KEY", @uid=nil, @api_key="MY_API_KEY",
@session_key=nil, @secret_from_session=nil>, @hometown_location=nil,
@id=nil, @uid=19400903, @current_location=nil, @pic=nil, @friends=nil,
@populated=false>

Any other toughts?

Thanks much,
Ted

Pavel Obod

unread,
Aug 13, 2009, 1:22:06 AM8/13/09
to facebooker
So it seems you can do
"@facebook_user.publish_to(@facebook_user, :message => "this is
a test for my wall")" in console - does it work?

I have no Idea yet how it could be ok with creating session in console
and problems with code. I will think about it. How do you think
yourself?

Ted K

unread,
Aug 13, 2009, 2:12:48 AM8/13/09
to facebooker
No, it doesn't work in the console either. I still get an Invalid
Parameter error. I really have no idea what's wrong. I've looked
through all of the source code that relates to what my console throws
at me, and all I gather is that Facebooker is throwing a standard
Invalid Parameter error, although I can't figure out what my Invalid
Parameters are.

For the time being, I'm going to try and get some FBJS to load after
my create action with either FB.Connect.streamPublish or
Facebook.streamPublish.

If anyone has any other ideas, I'd be delighted to hear them. Thanks,

Ted

Pavel Obod

unread,
Aug 13, 2009, 3:07:37 AM8/13/09
to facebooker
I little bit confused.
First you are writing :

Facebooker::Session::MissingOrInvalidParameter in
StatusesController#create
Invalid Parameter

It means, you have error when you are creating session, is not it?

But than you are trying in console and "session =
Facebooker::Session.create " works fine. And probably you have error
when you are posting in the stream. So what error do you have in this
case? It should be different from :

Facebooker::Session::MissingOrInvalidParameter in
StatusesController#create
Invalid Parameter

Also I hope you've got permission to publish from user. ;)

Anyway you can send source to my e-mail (excluding your API keys and
other) - I will try on my PC.
Sincerely, Pavel
Reply all
Reply to author
Forward
0 new messages