Posts

Showing posts with the label curl

Is it possible to upload a file with cURL from a pipe?

Is it possible to upload a file with cURL from a pipe? I mean POSTing a standard file upload form. Usual command line contains this switch in this case: -F "Filedata=@filename.zip" However when I try to feed a named pipe made by linux command "mkfifo", eg. "mkfifo filename.zip", I always get an error message on the producer side: curl: (23) Failed writing body (1856 != 16384) And also some error message appears at consumer side of the fifo. I fed my fifo with another curl command on producer side, eg.: curl http://example.com/archive.zip > filename.zip And on consumer side: curl http://example.com/fileupload.php -F "file=@filename.zip" When I pass a Content-Length HTTP header at the consumer side of my fifo, I don't get error message at the producer side, but error message still appears at the consumer (uploading) side, unsuccessful upload. curl http://example.com/fileupload.php -F "file=@filename.zip" -H "Content-Length: ...

CURL get page emty?

CURL get page emty? I have a very weird case as follows : This my CURL function : function get_data($url) { $ch = curl_init(); $timeout = 500; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } I have a txt file content link line by line. I get all that link to an array and tried to get content : $itemLink = file($LinkFile); if(empty($itemLink)){ echo "endFile"; exit(); } echo $itemLink[0]; //https://stackoverflow.com echo get_data($itemLink[0]); The result return empty but when i tried put direct link to my function like this : echo get_data('https://stackoverflow.com'); Of course i can get full page normally. Anybody knows what going on ? See if curl_getinfo() can help you debug your curl request. Does get_data(trim($itemLink[0])) help at all by any chance? ...

Microsoft Graph REST API invalid client secret

Microsoft Graph REST API invalid client secret I have the following POST call I need to make. However, even if I provided the right client id and secret id, my call is getting rejected. curl POST https://login.microsoftonline.com/f02....e3/oauth2/token -H 'Content-Type: application/x-www-form-urlencoded' --data 'grant_type=authorization_code&redirect_uri=https://requestb.in/ac& source=https://graph.microsoft.com&client_id=1e1....-913d9 &client_secret=YmbSFYz.....4Uk=&scope=mail.read&code=AaAAA........on0a569' This is the error I receive: curl: (6) Could not resolve host: POST {"error":"invalid_client","error_description":"AADSTS70002: Error validating credentials. AADSTS50012: Invalid client secret is provided.rnTrace ID: 78d...a2brnCorrelation ID: 01....ab2rnTimestamp: 2016-12-14 01:46:47Z","error_codes":[70002,50012],"timestamp":"2016-12-14 01:46:47Z","tra...