I'm developing Facebook JavaScript apps on a daily basis, but keep stumbling into some code snippets I don't understand, on the Facebook Documentation, and other websites I visit.
I searched Google for CURL, and found some descriptions about it. I can't figure out how Facebook wants me to use it.
curl -F "title=Example Title" -F "description=Description" \
-F "start_time=1329417443" \
"https://graph.facebook.com/PAGE_ID/milestones?access_token=_"
It's nonsens for me. Can you help me understand in what context I can use it for Facebook , and maybe in general, and guide me in the right direction where to find more on the subject?
curl is a command line utility that lets you send an HTTP request. It can be very useful for developing with web service APIs. I believe it comes pre-installed with most linux distros but you would need to download and install it for Windows. (It probably comes with Cygwin but can be installed on its own as well.)
I would suggest making sure it's directory is added to your PATH environmental variables. Again, probably not a problem in linux but you will need to do this manually in windows.
curl is a command to fetch requests. The -F (--form) argument is used to specify form POST parameters.
Citation from man curl:
-F/--form <name=content>
(HTTP) This lets curl emulate a filled-in form in which a user
has pressed the submit button. This causes curl to POST data
using the Content-Type multipart/form-data according to RFC
2388. This enables uploading of binary files etc. To force the
'content' part to be a file, prefix the file name with an #
sign. To just get the content part from a file, prefix the file
name with the symbol <. The difference between # and < is then
that # makes a file get attached in the post as a file upload,
while the < makes a text field and just get the contents for
that text field from a file.
curl is a way of fetching items. The -F is one of many parameters...
http://curl.haxx.se/docs/manpage.html
Also:
Have you seen http://developers.facebook.com/docs/reference/api/batch/
and it could be useful for something like:
http://chaolam.wordpress.com/2010/06/07/implementing-facebook-real-time-updates-api-with-curl-examples/
of course FB docs use curl to show a common basic way to perform the request ... it depends on what platform language libraries are you using the actual way to perform the graph http request
...so that if you are Facebook JavaScript developer you have to use XMLHttpRequest (or i suppose facebook js lib calls)
Related
how do I manage to execute a Python-file or a bash-script on a server via a press of a html-button without using a framework?
I have tried several versions of Ajax-Calls suggested in answers to similar questions, but none of them seem to work for me.
Note: Im using an Apache-Server on a RaspberryPi
According to apache documentation, you should configure apache to run CGI script, define an url prefix that maps a directory that contains your script and finally your script must return output in a particular way, or Apache will return an error message.
So, for example, if you define an url prefix like:
ScriptAlias "/cgi-bin/" "/path/to/your/script/cgi-bin/"
you can create a simple anchor to execute your script, you don't need to use ajax for this.
click me
To successful run your script you should follow apache directive in "Apache Tutorial: Dynamic Content with CGI"
the url link : https://live.eservice-hk.net/viutv
will return the text results (one text line) and show it on the browser.
I wanna to get those results via wget but I can't.
Then I watch the website page source and discovered that the page was generated by javascript.
How do I get the results instead of the javascript?
No! You cannot wget (or even curl) the dynamically generated javascript result from the page. You need a webdriver like Selenium for that or maybe use Chrome in Headless Mode.
But for that particular page (and more specifically for that particular text result), you can use curl to get the text-link:
curl -X POST -d '{"channelno":"099","deviceId":"0000anonymous_user","format":"HLS"}' https://api.viu.now.com/p8/1/getLiveURL | jq '.asset.hls.adaptive[0]'
Note: The POST data and link is taken from the page's source. jq is a nice, little command line utility to handle JSON data on command line.
I wonder if someone can give me an example about how "node-remote" works if I want to run some of the logic/functions of my application from the server.
Like, I don't know what to do after adding "node-remote" : "hostip" into package.json, what should my server provide? .js file that has the functions I want to run? So is it like: "node-remote" : "myappserver.com/funcs.js" ? I am so confused about this...
I can't find enough information on web about this, so some help or at least a better explanation of "baconface"'s reply from this link would be so helpful: https://github.com/nwjs/nw.js/issues/3278
node-remote is used for to expose node.js + nw.gui APIs for html script tags and javascript files coming from your website. That's it! You can use require, objects like global, process in these files.
node-remote parameter itself expects a domain name or ip address of hosts you want nw.js to allow to use node.js APIs for these hosts while other hosts can't access them.
Little example:
configure simple package.json and set node-remote parameter to github.com on it.
save package.json.
open nw application.
open page https://github.com/ on it.
open Developer Tools.
in console type require('fs').writeFileSync('test.txt', 'Hello, World!'); and hit enter.
Now you should see test.txt file in nw's root directory.
delete test.txt.
edit your package.json and remove node-remote field.
repeat [2..6] actions.
Now you should see error like "require" is undefined in DevTools console
Hope this helps.
Sicne this has been posted "node-remote" has change slightly. Here is an example:
"node-remote": "*://*",
Direct Links:
Notes about changes from v0.12 to v0.13 - http://docs.nwjs.io/en/latest/For%20Users/Migration/From%200.12%20to%200.13/
Formatting of "node-remote": http://docs.nwjs.io/en/latest/References/Manifest%20Format/#node-remote
again. I'm making a PL/SQL generated HTML5 web page. It's running a Oracle 10g XE server. Okay, now when the setup is clear, my problem - I need to include a Java Script file in the page. Simply
HTP.P('<script type="text/javascript" src="js/ScriptFileName.js"></script>');
Doesn't work of course. So i created a folder object and granted read,write to PUBLIC. Then changed the string to match the newly created object, instead of path. Still doesn't work. I know, i can write
HTP.P(<script type="text/javascript"> MY JAVA SCRIPT HERE</script>);
And i've done so with other scripts(Even had to write CSS this way). But this time this will not work. Reason being - the JavaScript i'm trying to run was normalized(or rather unnormalized), so it's written all in one line. And there is a lot of it too. I tried to reverse it to normal, but faild many a time.
So, I went online and searched for a solution. Found one. It seem's that this include should go not to the page, but to server config. Makes sense, since PL/SQL is server sided. But when i went looking for the usual httpd.conf, it's nowhere to be found in Database directory.So i went online again, result - NOT A WORD OF WHERE THE HELL ARE HTTP SERVER CONFIGS IN 10gXE IN ANY ORACLE MANUALS. Searched some forums - exactly 1 person asked where httpd.conf in XE is, and didn't get an answer. Please, help. I'm desperate.
P.S. I don't use APEX. I don't get that mumbo-jumbo. So i write in Notepad and run the scripts in SQL line.
Firstly, XE has its own built in HTTP server called the 'Embedded PL/SQL Gateway' or EPG. But you don't HAVE to use that. You can use an Oracle HTTP Server with the mod_plsql plugin. Or you can use the Apex listener.
The question is on what server is "ScriptFileName.js" ?
Is it a flat file on the database server ? If so, you'll need to use the Oracle HTTP Server (or Apache or similar) to serve it. The database is pretty much unaware of files on its server and the EPG can't deliver them. [At least not in any practical sense, you could do weird things with chicken entrails and UTL_FILE, but you don't want to go there.]
Is it a file stored in the database ? That sounds exotic, but it is pretty much how all the CSS, images etc are served up through the EPG. The best explanation on how to get files in and out of there is by Dietmar
Is it a file stored on a separate machine ? Often the best answer. The "src=" directive will be read by the end users browser. That will do an HTTP get to the URL. It doesn't have to be a URL on the same domain/host as the rest of the page.
I'm making a small app in Adobe Air which I need to interact with the Github Gist API. However I'm kind of stuck.
If you're not familiar with Adobe Air you can still help, the XMLHttpRequest javascript object can do cross domain requests, as there is no domain as such. So theres nothing Adobe Air specific here.
Where I'm stuck is I think I need to authenticate myself then make the POST. I just don't understand it
The problem with your script is that though you're sending a POST method, you're adding the data in the URL as though it were a GET. You just need to change xmlhttp.send(NULL) to xmlhttp.send(data), where data is the query data you were appending to the gists URL before (including the file and authentication information).
As a simple example, here's an excerpt from a bash script creating a new gist:
#!/usr/bin/env bash
if [ -z "$(git config github.token)" ]
then echo "warning: no api key found, to add follow instructions on github account page."
else echo "attempting to create a new gist using your github authentication..."; fi
SHA=$((curl https://gist.github.com/gists --include \
--data login=$(git config github.user) \
--data token=$(git config github.token) \
--data action_button=private \
--data 'file_ext[gistfile1]=txt' \
--data 'file_contents[gistfile1]=Hello World, this is an example gist!' \
| perl -e 'for(<>){if(/^Location: https?:\/\/gist.github.com\/([0-9a-f]+)/){print $1}}')2>/dev/null)
echo "New example gist created at https://gist.github.com/$SHA"
You shouldn't have to authenticate the user.
The XMLHttpRequest will just have to have the user name and the users API token included in the request.
Looking at the example ruby script provided by github here, you just have to provide the following attributes:
File Extenstion
file name
content
If the gist is private or not
User login
User API Token
python and perl versions of the script