All,
Currently I have a Facebook page that gets updated every few minutes using the cURL command. The command is :
curl.exe -kF "access_token=XXX" -F "message=YYY" https://graph.facebook.com/<appID>/feed
How can I programmatically implement the -k and -F in PHP?
[edit-05/24 - 15:59EST]:
-k flag: Allow connections to SSL sites without certs (H)
-F: -F/--form Specify HTTP multipart POST data (H)
I am not sure if message and access_token should be passed as POST fields. Can anyone please guide me on this?
I am getting the error:
{"error":{"type":"OAuthException","message":"(#803) Some of the aliases you requested do not exist: 1.8800586791358e 14"
}}* Connection #0 to host graph.facebook.com left intact
You will need to use the function curl_setopt().
View the documentation of CURLOPT_SSL_VERIFYHOST and CURLOPT_POSTFIELDS.
Related
I am trying to access the following URL using cURL:
http://bizsearch.penrithcity.nsw.gov.au/eplanning/Pages/XC.Track/SearchApplication.aspx
However, when I attempt to access the web page I am redirected to:
http://bizsearch.penrithcity.nsw.gov.au/eplanning/Common/Common/terms.aspx
I tried utilizing the following cURL command to get passed this:
curl --cookie-jar "CookieTest.txt" url(common terms) -d "ctl00$ctMain1$chkAgree$chk1=on&ctl00$ctMain1$BtnAgree=I Agree"
curl --cookie "CookieTest.txt" url(search application)
Any help would be greatly appreciated as I am new to cURL and am having difficulty troubleshooting. I am wanting to pull the XML from the search application page.
There are several other posts in reference to this problem. The difference here is that I am willing to give out the troublesome url.
This works:
curl https://pas-gdl.overdrive.com/advanced-search
This does not work:
$pagesource = shell_exec("curl https://pas-gdl.overdrive.com/advanced-search");
I get the dreaded 51 error: "curl: (51) SSL: no alternative certificate subject name matches target host name 'pas-gdl.lib.overdrive.com'"
There is a wildcard ssl cert involved. I have attempted to figure out what the command line curl is doing by default as a possible solution. However, seeing as I am just executing the same command via shell_exec there should be zero difference.
The command line option produces the advanced-search html and the shell_exec does not. Any information as to why would be greatly appreciated.
use php curl instead
also look into how to curl https
So far, I have seen numerous examples on how to PUT a file in a Tika server using curl. For example from the Tika wikipage documentation we can conclude that if your file is in location
"file:///var/www/html/files/a.pdf"
in your machine and the Tika server runs on
http://localhost:9998
then using curl you can do a
curl -s "file:///var/www/html/files/a.pdf" | curl -X PUT -T - http://localhost:9998/meta
to get the metadata.
However, I haven't seen an example where the complete URI is given that makes the above JAXRS tika server providing the same result as the curl command above but showing the result in my browser this time and not on the terminal.
So, say I am visiting on my browser the tika server URI:
http://localhost:9998
what do I have to append to this URI in order to get the metadata like the curl command in my browser?
Thank you forum
The answer is in the curl command in your question:
curl -s "file:///var/www/html/files/a.pdf" | curl -X PUT -T - http://localhost:9998/meta
The URL you need to put to is at the end - http://localhost:9998/meta
You can also find all the endpoints in a Tika server from the listing linked from the welcome page when you go to the server with your web browser, and from Tika Wika Page for the Server
I have a page (realized with a php framework) that add records in a MySQL db in this way:
www.mysite.ext/controller/addRecord.php?id=number
that add a row in a table with the number id passed via post and other informations such as timestamp, etc.
So, I movedo my eintire web applicazione to another domain and all HTTP requests works fine from old to new domain.
Only remaining issue is the curl: I wrote a bash script (under linux) that run curl of this link. Now, obviously it does not works because curl returns an alert message in which I read the page was moved.
Ok, I edited the curl sintax in this way
#! /bin/sh
link="www.myoldsite.ext/controlloer/addRecord.php?id=number"
curl --request -L GET $link
I add -L to follow url in new location but curl returns the error I wrote in this topic title.
It would be easier if I could directly modify the link adding the new domain but I do not have physical access to all devices.
GET is the default request type for curl. And that's not the way to set it.
curl -X GET ...
That is the way to set GET as the method keyword that curl uses.
It should be noted that curl selects which methods to use on its own depending on what action to ask for. -d will do POST, -I will do HEAD and so on. If you use the --request / -X option you can change the method keyword curl selects, but you will not modify curl's behavior. This means that if you for example use -d "data" to do a POST, you can modify the method to a PROPFIND with -X and curl will still think it sends a POST. You can change the normal GET to a POST method by simply adding -X POST in a command line like:
curl -X POST http://example.org/
... but curl will still think and act as if it sent a GET so it won't send any request body etc.
More here: http://curl.haxx.se/docs/httpscripting.html#More_on_changed_methods
Again, that's not necessary. Are you sure the link is correct?
How to inspect CURL requests?
My PHP scripts are hosted on IIS and I want to find some debugging tool for CURL.
Could you suggest something in fiddler-style?
(Or maybe there is a way to use fiddler itself, I failed to do so because if I make my CURL to tunnel through proxy 127.0.0.1 it makes CONNECT requests instead of GET)
wireshark is not working for HTTPS but for HTTP only.
Can you change your curl script to use HTTP ?
Use curl -v for verbose mode.
From man curl
-v/--verbose
Makes the fetching more verbose/talkative. Mostly useful for debugging. A line starting
with '>' means "header data" sent by curl, '<' means "header data" received by curl that
is hidden in normal cases, and a line starting with '*' means additional info provided by
curl.
Note that if you only want HTTP headers in the output, -i/--include might be the option
you're looking for.
If you think this option still doesn't give you enough details, consider using --trace or
--trace-ascii instead.
This option overrides previous uses of --trace-ascii or --trace.