English 中文(简体)
Updating facebook status with message from a Javascript variable
原标题:

Is there an easy way to let users update their status on Facebook with a message I have in a JavaScript variable? I know there s a URL you can use to share a link, which looks like:

<a href="http://www.facebook.com/sharer.php?u=www.fthisclass.com/jshoregen.html&t=title">testlink </a>

That doesn t fill in a status update when it takes them to the share page. Is there a way I can have that pre-filled, or have their status automatically updated?

Thanks!

Edit: Not quite what I m going for. I can use PHP if necessary (although I have very little experience with it), but I don t want to have to bug users with allowing an application, or have to deal with actually writing a facebook app. I just want to give users a premade status update, so all they have to do is click the share button. Thanks again!

Edit 2: So the api looks promising, but a little complicated for me. It looks like it would involve getting permission from the user to set their status, and possibly something about setting up a cross-communications channel to let my site communicate with facebooks. Assuming I can do that, how do I go about using the Facebook Javascript api? I get the code (user_setStatus looks easy enough), but how do I tell my script that I m using Facebook s api? Thanks again...again!

问题回答

Try this:

http://www.facebook.com/connect/prompt_feed.php?&message=my%20awesome%20status

[EDIT] Link is not working please update it.

Is the facebook javascript API not what you re looking for? It seems to expose the entire REST-ful API as a javascript library.

users_setStatus(...) looks promising.

Not sure if you re using PHP but here s a link that shows you how to use the Facebook API to update the status. You could call a page with Ajax from Javascript, passing in the variable and have that posted to the Facebook status message.

http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/

Using just mcqwerty solution you ll get an annoying resize screen effect.

But, you can add a parameter in order to avoid this flickering. Display touch will avoid this.

https://www.facebook.com/connect/prompt_feed.php?display=touch&message=Hiall

Here is working example which requires application ID, but fully working and it is easy to implement:

<a href="http://www.facebook.com/dialog/feed?app_id=123050457758183&link=http://www.build.server.com&picture=http://fbrell.com/f8.jpg&
  name=Some%20Encoded&Message=Reference%20Documentation&
  description=Using%20Dialogs%20to%20interact%20with%20users.&
  redirect_uri=https://arapskirjecnik.web44.net/"> Share with FB</a>

see more here

here is the way which works and it doesn t requires facebook application id:

<a onClick="window.open( http://www.facebook.com/sharer.php?s=100&amp;p[title]=Title&amp;p[summary]=summary&amp;p[url]=www.build.server.com&amp;p[images][0]=http://fbrell.com/f8.jpg , sharer , toolbar=0,status=0,width=548,height=325 );" href="javascript: void(0)">Insert text or an image here.</a>

As you can see from above code you can enter custom title, summary, link and images.

and if you want to automate, to share current link, youst replace this part of the code in upper example:

p[url]= + document.URL + &amp;p[images]




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签