How to get Facebook share count of specific url using javascript - javascript

Hi I've looked all over the internet for days to find the answer to this question.
I'd like to know how to get the share count of a specific url using javascript and then sending the value server side using ajax.
I'd really appreciate it if you could help me out :)

You can use their graph functional: http://graph.facebook.com/
You will have to load the page like this: http://graph.facebook.com/http://graph.facebook.com/
And the results would be returned back via json. But be carefull with long urls, they are not always returned correctly.
Hope it'll help!

Related

I need to get an Instagram User ID# for use in Google Script

I'd like to take a username and plug it into this format
https://www.instagram.com/{username}/?__a=1
thanks to this thread for that tip
I then need to follow that link in java, and when doing so it presents the following page code, which I've abridged to save space. I used professional Skateboarder Nyjah Huston as my example.
{"logging_page_id":"profilePage_8223552","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"Sender\ud83d\ude08\n#nikesb #monsterenergy #elementbrand #blackplaguebrewing #socialcbd #priverevaux","blocked_by_viewer":false,"restricted_by_viewer":null,"country_block":false,"external_url":"https://www.nike.com/t/sb-nyjah-free-skate-shoe-oKwn7N/AA4272-300","external_url_linkshimmed":"https://l.instagram.com/?u=https%3A%2F%2Fwww.nike.com%2Ft%2Fsb-nyjah-free-skate-shoe-oKwn7N%2FAA4272-300&e=ATMW9Q8NwN2Mcwm_Bd5I8DeuAKP4L7IHpy_PdylDnGU8qqokJU6Z1kh_emEIVfJ1q8Xtq1b0&s=1","edge_followed_by":{"count":3969537},"followed_by_viewer":false,"edge_follow":{"count":694},"follows_viewer":false,"full_name":"Nyjah Huston"
As you can see, the User ID is one of the first things on the page
{"logging_page_id":"profilePage_8223552"
the user id being 8223552 in this case. I'm quite new to java, and I need to know how to follow that link and parse that data in order to turn the user id into a var for use in my google script. Thank you for your help!
You can easily parse this JSON content to a object that has only the information you need:
class UserInformation{
private String logging_page_id;
}
I suggest this option because if you need in the future to get another info, you can easily just extend the object.
How to do the conversion, please reference to this stackoverflow

How can I convert an XML Object into a Javascript Object?

I have a project I need to do that requires the use of xml and javascript, however I'm not experienced in either.
Basicly its for a company that posts jobs in an rss feed using xml, and what they need is to have a page that allows a user to type in a search query, click a search button and have a list of available jobs returned back to them with only the title and the link, and upon clicking the link they will be directed to the full rss xml item. which they can then read.
Now as far as my logic goes, I don't know how to use jquery and quite honestly I don't think its necesary, I think that all this project needs is a bit of ajax however firstly one would need to create an xml object, convert it to a javascript object and only then manipulate it. etc...
If anyone has any insight I'd really appreciate it.

Adapting Etherpad to react on new params

I try to adapt etherpad so it is only accessible if certain params are sent with the request.
For example I want a certain pad just to be displayed if there is a unique id provided like
http://myetherpad.com/thepadid?myparam=blub
Does anyone know where exactly I can parse the params? I searched all the js-files but didn't find exactly what I am looking for.
I found out that there is some kind of request object. You can access it like
request.params.padId
But I also don't know where to search for the implementation of this object.
I hope somebody can help me. Thanks :)
You could probably hack something into the code at https://github.com/ether/pad/blob/master/etherpad/src/etherpad/licensing.js#L153
But if all you need is some kind of password protection, there are easier ways. The easiest would be to use something that is built in to your web server, or to use the built-in pro functionality -- more on that on http://etherpad.org/2010/10/14/241/
(Your idea with using URL-parameters for password could be simplified; just use a complicated pad name and only those with the URL will find it. Having a "nice" pad name and adding a complicated password at the end doesn't protect the pad at all.)
For anyone with the same problem: You can get the GET-parameters via
request.headers['Referer']
It returns the URI the user called. But I still don't know how to do it properly (or get the POST parameters).

XML File Parse in javascript how to. Large File maybe use SAX?

G'day All,
I am pulling my hair out, getting headaches and my eyes hurt. I have been hither and thither and I seem to get whither.
This will be my first experience with xml and would really want to get this working. It is a large file. Well large in my eyes +-5mb. I can not imagine that this file would be loaded into memory to process. Users will get a bit peeved with this.
Basically we are using a 3rd parties site to do our ecommerce. So we have no access to the database other than via the admin area.
What we want to do is make sure that there is no stuff ups when it comes to addresses. Therefore we got this xml file put together listing all postcodes with areas and states:
<?xml version="1.0"?>
<POSTCODES>
<PostCode id="2035">
<Area>2035 1</Area>
<Area>2035 2</Area>
<Area>2035 3</Area>
<State>NSW</State>
</Postcode>
<PostCode id="2038">
<Area>2038 1</Area>
<Area>2038 2</Area>
<Area>2038 3</Area>
<State>NSW</State>
</Postcode>
<PostCode id="2111">
<Area>2111 1</Area>
<Area>2111 2</Area>
<Area>2111 3</Area>
<State>NSW</State>
</Postcode>
</POSTCODES>
Someone suggested SAX but suddenly died when asked how? The web is not helping unless I am not looking properly. I see a lot of examples. Either they do not show how to read the file but rather do it from a textarea or the example is in java.
What do we want? User enters a post code of 2038. We want to go to the javascript with that data and have returned to us all the suburbs that full within that post code.
Anyone out there that can please tell me what to download and how to use it to get what i need?
Please, please, please. It is hard to see a grown man begging and crying but I am.
Sounds like you want a script on the server which will suggest suburbs based on the users postcode selection? You could use jQuery's ajax functionality to do this.
You might also be able to use jQueryUI's autocomplete control to parse XML and make suggestions: http://jqueryui.com/demos/autocomplete/#xml
It's also possible to do this entirely in javascript without any script on the server side, but it would be pretty slow at loading if the XML file is 5MB. You might be able to get a significant reduction in file size thought by gzipping it before transmission from the server.
If you need to parse this in Javascript, you can use jQuery.
http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery

Where to start with JSON? (Closed)

I'm trying to get started with JSON. I've set the link to the JSON.js file using a script link, and I've set my objects using JSON, but it returns no results at all when I try to refer to the object. The JSON doesn't seem to be working at all. If anyone could point me in the right direction it'd be appreciated. I've looked all over the internet and haven't found much to help me.
Thanks guys. The JSON website helped me figure it out
Get Firefox, get Firebug, learn to use it to see what javascript is being loaded, and where the errors are.
Oh, and post some code.
Take a look-see at this
http://json.org/
basically you need to understand that json is a way to stream javascript object literals and arrays from a server to the client (and vice-versa). Open up firebug/webkit and in the console try
var obj = JSON.parse('{"test": 1}')
and you will see that obj is an object literal with a test property.
edit -- note that the link I provided mentions that json is a "is a lightweight data-interchange format" -- so its does not need to be javascript specific. But I think in practice you will get the most mileage using json in conjunction with javascript.
Here's a couple of links that might help:
http://secretgeek.net/json_3mins.asp
http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Object_Notation_)

Categories

Resources