I am a noob on cURL - I am trying to authenticate a session with a server according to the documentation provided to me.
When I try the below command from OSX it works fine and I end up getting a "Session Successfully Authenticated" message.
But, when I try the exact same command from Windows (tried on 3 diff machines) It gives me "Authentication failed!" message.
curl --request POST http://xx.yy.zz.nnn/login.php --data 'username=ams' --data 'password=<password>' -c cookie.txt -v
In the verbose, the only difference I see between the two systems are - the content-length = 34 (in windows) and content-length = 30 (in OSX).
When I do a cURL from windows, is there any special consideration that needs to be taken into account when sending data??
Any help/pointer to resolve this is much appreciated. Thanks.
Related
At the moment I'm trying to analyze a PHP Application. The Profiler starts working and stops then at 1/10. While this the memory usage of the docker container goes straight up. After the failure in the blackfire log is an entry like "Profile data is trunctated."
I've tried to request it with curl over the cli and with firefox. If I call the page normally in Firefox or via curl I get the correct response
curl --request GET --url 'http://xxx/index.php?eID=contacts&optigemId=1335600' --header 'cookie: fe_typo_user=xxxx' --cookie fe_typo_user=xxx
By chance, do you have any disabled PHP functions in your php.ini or any other PHP configuration file for your domain ?
(disable_functions in php.ini, see https://www.php.net/manual/en/ini.core.php#ini.disable-functions)
I had to delete the function opcache_get_status from the list of disabled functions to get Blackfire to work with my PHP configuration on Plesk.
Cheers.
I am having an issue with running my PHP application from the command line.
I recently created a new Google Cloud Engine CentOS instance to host my PHP application.
This application has been running away fine on a different RHEL box.
The application is kicked off from a PHP script using a command similar to...
$command = 'bash -c "exec nohup setsid runPHPScript > /dev/null 2>&1 &"';
exec($command, $output, $returnVar);
runPHPSCript is a linux script that essentially runs the actual PHP command...
php myScript.php
myScript.php then goes off and connects to various webservices etc...
When I try to run this on my new instance (bearing in mind this all worked fine on my RHEL box) I get the following SOAP error...
(faultcode: HTTP, faultstring: Could not connect to host)
The SOAP setup/connection to the endPoint WSDL is actually successful but as soon as I try to send the request I get the error above.
I've been debugging this and reading up a bit and can confirm the following...
HTTP & HTTPS are both enabled on the GCE instance.
I have verified that both PHP & Apache are using the same php.ini (more on this below)
I have checked both configurations using phpinfo() and php -i and can see the various SSL entries in the data
The strange part is that if I open myScript.php in a browser (its a LAMP stack) it connects fine to the webservice and I can see the valid response. This lead me to think the problem was different php.ini's being used.
Also, at the command prompt, if I just run myScript.php directly it also works fine...
php 'myScript.php'
returns a valid response too.
So the problem only seems to occur when I try to kick off the application using BASH.
Anyone got any ideas?
Robert
Cleaning up.
As per Raidenace suggestion, just running exec directly worked fine too...
"just curious...why cant you just do an exec("php myScript.php"); in your code direcctly?"
I'm simply trying to do PUT/DELETE requests in my PHP application, but after the first 5 requests, the data is lost.
I've reduced the code to this to illustrate the issue:
index.php
$h = fopen('php://input', 'r');
var_dump(fread($h, 1024));
die();
CLI input
curl -X PUT http://cms.dev.com -d '{"foo":"bar"}'
So, for the first 5 times I run that, I get:
string(13) "{"foo":"bar"}"
Then, from the 6th onwards, I get:
string(0) ""
I'm running PHP Version 5.6.0beta1 and Apache/2.2.26, installed on OSX 10.9.3 via Mac Ports.
POST works fine.
EDIT It might be worth noting this can be replicated on 2 other colleague's MacPorts setups, but can't on MAMP, which seems to act correctly.
Does anyone have ideas? It's driving me crazy!
Thanks,
Todd
I cannot reproduce this using the built-in webserver, which might indicate an interaction between apache and php.
Try running :-
php -S localhost:8001
in one terminal and
for n in `seq 1 100`; do curl -X PUT http://localhost:8001 -d '{"foo":"bar"}'; done
in another - see if it's limited to php or at the mod_php level.
My testing is on a linux box with 5.4.9 fwiw.
Upgrading to php 5.6beta3 fixed the issue.
Must have been a bug in php 5.6beta1!
Hopefully this'll help someone else :)
I'm not using PHP, but another language for this.. just FYI. However, I included the PHP as a tag, just in case someone there has a solution...
At the moment I'm first trying to get the string right (to download a file through curl from a remote server to a local domain). Anyway, the password contains a percent sign (%).
When I do this, I get the following error on my command line:
curl: (67) Access denied: 530
The 67 is an error code from curl (see also http://curl.haxx.se/docs/manpage.html) and means that "The user name, password, or similar was not accepted and curl failed to log in."
Now say the original string would be this:
curl -u Login:Pass%Word
I've tried the following solutions that I found on the net:
curl -u Login:Pass%25Word
curl -u Login:Pass%%Word
curl -u Login:Pass^%Word
curl -u Login:Pass^%%Word
However.. I ALWAYS get the Access denied.
Could someone help me out, please?
I have just replayed your case: made user test / some%password and secured my site.
These two commands works:
curl -u 'test:some%password'
curl -u test:some%password
It seems you just using wrong password or misspelled server name
Have you tried it using ASCII code?
curl -u Login:Pass%25Word
Source
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.