Updating facebook status with message from a Javascript variable - javascript

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:
testlink
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&p[title]=Title&p[summary]=summary&p[url]=www.build.server.com&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 +'&p[images]

Related

How to import data from website and use it in my web page using JS?

I want to use particular data of some website and show it my webpage.
I wanted to make an web article about the best Youtube Channels. Surely I have to write information about these channel.
For example, There is a youTube channel called "Example" and this channel has url like:
https://www.youtube.com/user/justforexample
I need amount of subscribers of it. In page source, it is inside tag:
<yt-formatted-string id="subscriber-count" class="style-scope ytd-c4-tabbed-header-renderer">4.5M subscribers</yt-formatted-string>
(actually i dont know if there is tag like that but tag maybe not only , it maybe <span> or <div>)
What I want is numbers. It should be in real time.
For instance, in 2020 this channel has 4.5M subscribers, after few years it turn out to be 5.8M.
Above was just example, it may not be only Youtube page, any website.
I know JS and jQuery and hope you help me :)
Thank you
Try sending an HTTP GET request to that url
Read about jQuery ajax function for more information: https://api.jquery.com/jquery.ajax/
Note that additional headers might be needed, try and analyze the response

How refresh page when a user insert a row into the database?

i'm doing a little group chat that every message are stored into the database. When a message is store the page need to refresh. how can i do a thing like this ?
You can use Web Sockets to keep open a connection to the server. You can use the ratchet library: http://socketo.me/ Check the documentation to have a overview of this module.
Also, you can check this page to have an overview of this revolutionary system http://www.html5rocks.com/es/tutorials/websockets/basics/
EDIT:
However, you can use AJAX, but make it simple with JQuery. Don't complicate your code ;)
Ajax is simple to use with JQuery. Don't make a Text area becouse it is ugly. Make a in your document and other in an appart document and call it using:
$.get("theotherpage.html", function(data){
$("#localdiv").html(data);
});
Give a look at this page teaching you to use JQuery AJAX: http://www.w3schools.com/jquery/jquery_ajax_get_post.asp
You want to use AJAX. With AJAX you can refresh parts of the page, without refreshing the entire page.

Is it possible to manipulate the likes of a facebook image?

We are creating a website based on images. Those images are uploaded on a facebook page too. I managed to get the albums, the images inside them and the likes that they have through Facebook Graph API. I'm using javascript to fetch all these urls and json to parse all the responses.
We could not found a way to get a like button or create one of our own that could manipulate the likes of each image and change them on facebook too.
I dig through Graph docs, i tried use the social plugin with urls like that https://graph.facebook.com/ but the results from json that fb graph gives ( witch are the true ones checked with the images ) are different from those in social plug in.
I'm not posting any code because i do not thing it is needed. But if someone need more details or code please feel free to ask.
I can use only Javascript for this task server side scripting not allowed.
Sorry for my enlgish, thanks in advance.
Well, if you have a look at the docs at https://developers.facebook.com/docs/plugins/like-button/ you could see that the URLs need to be some "public" URL, i.e. the "link" field of a photo object (as of https://developers.facebook.com/docs/graph-api/reference/photo).

Facebook makes their AJAX calls through iframe?

I want to implement AJAX like facebook, so my sites can be really fast too. After weeks of research and also knowing about bigPipe (which is not ajax).
so the only thing left was how they are pulling other requests like going to page/profile, I opened up firebug and was just checking things there for what I get if I click on different profiles. But the problem is, firebug doen'tt record any such request and but still page gets loaded with AJAX and changes the HTML also, firebug does show change on html.
So I'm wondering, if they are using iframe to block firebug to see the request or what? Because I want to know how much data they pull on each request. Is it the complete page or only a part of page, because page layout changes as well, depending on the page it is (for example: groups, page, profile, ...).
I would be really grateful if a pro gives some feedback on this, because i cant find it anywhere for weeks.
The reason they use iframe, usually its security. iframes are like new tabs, there is no communication between your page and the iframe facebook page. The iframe has its own cookies and session, so really you need to think about it like another window rather than part of your own page (except for the obvious fact that the output is shown within your page).
That said - the developer mode in chrome does show you the communications to and from the iframe.
When I click on user's profile at facebook, then in Firebug I clearly see how request for data happens, and how div's content changing.
So, what is the question about?
After click on some user profile, Facebook does following GET request:
http://www.facebook.com/ajax/hovercard/user.php?id=100000655044XXX&__a=1
This request's response is a complex JS data, which contain all necessary information to build a new page. There is a array of profile's friends (with names, avatar thumbnails links, etc), array of the profile last entries (again, with thumbnails URLs, annotations, etc.).
There is no magic, no something like code hiding or obfuscation. =)
Looking at face book through google chromes inspector they use ajax to request files the give back javascript which is then used to make any changes to the page.
I don't know why/wether Facebook uses IFRAMEs to asynchroneously load data but I guess there is no special reason behind that. We used IFRAMEs too but now switched to XMLHttpRequest for our projects because it's more flexible. Perhaps the IFRAME method works better on (much) older browsers, but even IE6 supports XMLHttpRequest fine.
Anyway, I'm certain that there is no performance advantage when using IFRAMEs. If you need fast asynchroneous data loading to dynamically update your page, go with XMLHttpRequest since any modern browsers supports it and it's fast as HTTP can be.
If you know about bigPipe then you will be able to understand that,
As you have read about big pipe their response look like this :-
<script type="text/javascript"> bigpipe.onPageArrive({ 'css' : '', '__html' : ' ' }); </script>
So if they ajax then they will not able to use bigpipe, mean if they use ajax and one server they flush buffer, on client there will no effect of that, the ajax oncomplete only will call when complete data received and connection closed, In other words they will not able to use their one of the best page speed technique there,
but what if they use iframe for ajax,, this make point,, they can use their bigpipe in iframe and server will send data like this :-
<script type="text/javascript"> parent.bigpipe.onPageArrive({ 'some' : 'some' });
so server can flush buffer and as soon as buffer will clear, browser will get that, that was not possible in ajax case.
Important :-
They use iframe only when page url change, mean when a new page need to be downloaded that contains the pagelets, for other request like some popup box or notifications etc they simple send ajax request.
All informations are unofficial, Actually i was researching on that, so i found,
( I m not a native english speaker, sorry for spelling and grammer mistakes! )
when you click on different profile, facebook doesn't use ajax for loading the profile
you simple open a new link plain old html... but maybe I misunderstood you

Test browser history before going back via javascript?

I'm playing around with using some javascript to add extra functionality to a back button on my website. Right now I have a set of javascript that looks like this:
$(".back-link a").live("click", function(){
history.go(-1);
return false;
});
Now, it works great but I'm trying to make it as bulletproof as possible and one issue I foresee is that if someone lands on a project page and hasn't come to it via my home page then going back in their history one step will take them off my site. Obviously, this isn't what I want.
My guess is it would be a simple case of doing an if-statement but I'm not sure what or how to test for it. I suppose I could just test to make sure the base of the URL is my site but I'm not sure how.
Any tips or directions would be great.
No, it's not at simple as that. You can use the history collection to go back or forward, but you can't get the URLs in the history.
The only information that you can obtain about where the user comes from is the HTTP_REFERER string in the request header, but you have to use server side code to get that.

Categories

Resources