Search Results

Search found 5809 results on 233 pages for 'curl multi'.

Page 8/233 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Send SOAP via curl

    - by danrichardson
    Hi. This has been bugging me for days, i'm trying to send a SOAP post via curl but i just keep getting a 'couldn't connect to host' error but i really cant see how. I have an asp version which works fine with the same url and data, i think it's just a php/curl thing...? I currently have the following code (the CURLOPT_POSTFIELDS data is a valid soap envelope string) $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, "https://xxx.yyy.com:517/zzz.asmx" ); curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($soap_do, CURLOPT_TIMEOUT, 10); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, '<soap:Envelope>...</soap:Envelope>'); curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen('<soap:Envelope>...</soap:Envelope>') )); if(curl_exec($soap_do) === false) { $err = 'Curl error: ' . curl_error($soap_do); curl_close($soap_do); return $err; } else { curl_close($soap_do); return 'Operation completed without any errors'; } So any ideas why it just errors all the time? The asp version works fine! The code is; Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP") xmlhttp.Open "POST","https://xxx.yyy.com:517/zzz.asmx" xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8" xmlhttp.Send('<soap:Envelope>...</soap:Envelope>')

    Read the article

  • cURL Affects Cookie Retrieval in PHP?

    - by CJ
    I'm not sure if I'm asking this properly. I have two PHP pages located on the same server. The first PHP page sets a cookie with an expiration and the second one checks to see if that cookie was set. if it is set, it returns "on". If it isn't set, it returns "off". If I just run the pages like "www.example.com/set_cookie.php" AND "www.example.com/is_cookie_set.php" I get an "on" from is_cookie_set.php. Heres the problem, on the set_cookie.php file I have a function called is_set. This function executes the following cURL and returns the contents ("on" or "off"). Unfortunately, the contents are always returned as "off". however, if I check the file manually ("www.example.com/is_cookie_set.php") I can see that the cookie was set. Heres the function : <?php function is_set() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://example.com/is_cookie_set.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $contents = curl_exec ($ch); curl_close ($ch); echo $contents; } ?> Please note, I'm not using cURL to GET or SET cookies, only to check a page that checks if the cookie was set. I've looked into CURLOPT_COOKIEJAR, and CURLOPT_COOKIEFILE, but I believe those are for setting cookies via cURL and I don't want to do this.

    Read the article

  • Using curl to submit/retrieve a forms results

    - by Jason
    I need help in trying to use curl to post data to a page and retrieve the results after the form has been submitted. I created a simple form: <form name="test" method="post" action="form.php"> <input type="text" name="name" size="40" />e <input type="text" name="comment" size="140" /> <input type="submit" name="submit" value="submit" /> </form> In addition, I have php code to handle this form in the same page. All it does is echo back the form values. The curl that I have been using is this: $h = curl_init(); curl_setopt($h, CURLOPT_URL, "path/to/form.php"); curl_setopt($h, CURLOPT_POST, true); curl_setopt($h, CURLOPT_POSTFIELDS, array( 'name' = 'yes', 'comment' = 'no' )); curl_setopt($h, CURLOPT_HEADER, false); curl_setopt($h, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($h); When I launch the page with the curl code in it, I get the form.php page contents but it doesn't not show the variables that PHP should have echo'd when the form is submitted. would appreciate any help with this. Thanks.

    Read the article

  • Preserve name of file using cURL to transfer files

    - by Toby
    I'm transferring files from an existing http request using cURL like so... $postargs = array( 'nonfilefield' =>'nonfilevalue', 'fileentry' => '@'.$_FILES['thefile']['tmp_name'][0] ); $ch = curl_init('http://localhost/curl/rec.php'); curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_POST,TRUE); curl_setopt($ch,CURLOPT_POSTFIELDS,$postargs); curl_exec($ch); curl_close($ch); The only way I can get this to work is using the tmp_name, without this it won't send. However, I then lose the name value for when I want to name the file later. Is there some way to do this preserving the $_FILES array as it normally would be without curl? I'm also using an array of file fields in my script, so at the moment I have to convert my multidimensional array into a single dimension for this to work

    Read the article

  • Change post form data function into curl

    - by QLiu
    Hello Guys, In the old way in our website, when users clicks “logout” button. It runs a post form function; which will pass parameters (logout, sn) to external sites to execute “logout” function. Like: I do not want the users jump to the external site, therefore, i use curl to post data. (because we are in different domain, i guess Ajax request doesnot work ) Post the same data to execute logout function in external site. // create cURL resource $URL = "http://bswi.development.intra.local/"; //Initl curl $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $URL); // Load in the destination URL curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //Normal HTTP request, not SSL curl_setopt($ch, CURLOPT_POSTFIELDS, "logout=1"); // receive server response ... curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec ($ch); echo $content; curl_close ($ch); Do u think i am going in the right direction?

    Read the article

  • Curl, twitter oauth problem

    - by Darxval
    Does anyone see a problem with the following Curl call / how the Oauth request is built? (i am trying to get a correctly setup request so i can finish my app) So i am calling the following CURL call: C:\>curl -v -k --data-urlencode "status=Testing2" -H "Authorization: OAuth realm='', oauth_nonce=1276107867blah, oauth_timestamp=1276107867, oauth_consumer_key=yJDLH7BDdVi1OKIINSV7Q, oauth_signature_method=HMAC-SHA1, oauth_version=1.0, oauth_signature=NWU4MDdlNjk0OGIxYWQ1YTkyNmU5YjU1NGYyOTczMmU5ZDg5 YWNkNA==, staus=Testing2 " http://twitter.com/statuses/update.xml?status=Testing2 and i recieve this: * About to connect() to twitter.com port 80 (#0) * Trying 168.143.162.68... connected * Connected to twitter.com (168.143.162.68) port 80 (#0) > POST /statuses/update.xml?status=Testing2 HTTP/1.1 > User-Agent: curl/7.20.1 (i386-pc-win32) libcurl/7.20.1 OpenSSL/0.9.8n zlib/1.2.5 libidn/1.18 libssh2/1.2.5 > Host: twitter.com > Accept: */* > Authorization: OAuth realm='', oauth_nonce=1276106370blah, oauth_timestamp=1276106370, oauth_consumer_key=yJDLH7BDdVi1OKIINSV7Q, oauth_signature_method=HMAC-SHA1, oauth_version=1.0, oauth_signature=MjQzNDA1MGU4NGRmMWVjMzUwZmQ4YzE5NzMzY2I1ZDJlOTRkNmQ2Zg==, staus=Testing2 > Content-Length: 15 > Content-Type: application/x-www-form-urlencoded > < HTTP/1.1 401 Unauthorized < Date: Wed, 09 Jun 2010 18:00:22 GMT < Server: hi < Status: 401 Unauthorized < WWW-Authenticate: Basic realm="Twitter API" < X-Runtime: 0.00548 < Content-Type: application/xml; charset=utf-8 < Content-Length: 164 < Cache-Control: no-cache, max-age=1800 < Set-Cookie: k=209.234.229.21.1276106420885412; path=/; expires=Wed, 16-Jun-10 18:00:20 GMT; domain=.twitter.com < Set-Cookie: guest_id=127610642214871948; path=/; expires=Fri, 09 Jul 2010 18:00:22 GMT < Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCIm33h0pAToHaWQiJTkyMjllODE0NTdiYWE1%250AMWU1MzBmNjgwMTFiMDhkYjdlIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--8ebb3c62d461d28f8fda7b8adab642af66969f7e; domain=.twitter.com; path=/ < Expires: Wed, 09 Jun 2010 18:30:20 GMT < Vary: Accept-Encoding < Connection: close < <?xml version="1.0" encoding="UTF-8"?> <hash> <request>/statuses/update.xml?status=Testing2</request> <error>Could not authenticate with OAuth.</error> </hash> * Closing connection #0 my Parameters are setup like so: var parameters = [encodeURIComponent("status="+status),encodeURIComponent("oauth_token="+ac_token),encodeURIComponent("oauth_consumer_key="+"yJDLH7BDdVi1OKIINSV7Q"),encodeURIComponent("oauth_nonce="+nonce,"oauth_signature_method=HMAC-SHA1"),encodeURIComponent("oauth_timestamp="+timestamp),encodeURIComponent("oauth_version=1.0")] var join = parameters.join("&"); var eparamjoin =encodeURIComponent(join); The key is like so: var key=con_secret+"&"+ac_secret; Signature base string is: var signaturebs = "POST&"+encodeURIComponent(url)+"&"+eparamjoin; giving this: POST&http%3A%2F%2Ftwitter.com%2Fstatuses%2Fupdate.xml&status%253DTesting2%26oauth_token%253D142715285-yi2ch324S3zfyKyJby6WDUZOhCsiQuKNUtc3nAGe%26oauth_consumer_key%253DyJDLH7BDdVi1OKIINSV7Q%26oauth_nonce%253D1276107867blah%26oauth_timestamp%253D1276107867%26oauth_version%253D1.0 and signature built like so: var hmac = Crypto.HMAC(Crypto.SHA1, signaturebs,key ); var signature=Base64.encode(hmac); making the signature: NWU4MDdlNjk0OGIxYWQ1YTkyNmU5YjU1NGYyOTczMmU5ZDg5YWNkNA== Any help would be appreciated thank you!

    Read the article

  • CURL - HTTPS Wierd error

    - by Vincent
    All, I am having trouble requesting info from HTTPS site using CURL and PHP. I am using Solaris 10. It so happens that sometimes it works and sometimes it doesn't. I am not sure what is the cause. If it doesn't work, this is the entry recorded in the verbose log: * About to connect() to 10.10.101.12 port 443 (#0) * Trying 10.10.101.12... * connected * Connected to 10.10.101.12 (10.10.101.12) port 443 (#0) * error setting certificate verify locations, continuing anyway: * CAfile: /etc/opt/webstack/curl/curlCA CApath: none * error:80089077:lib(128):func(137):reason(119) * Closing connection #0 If it works, this is the entry recorded in the verbose log: * About to connect() to 10.10.101.12 port 443 (#0) * Trying 10.10.101.12... * connected * Connected to 10.10.101.12 (10.10.101.12) port 443 (#0) * error setting certificate verify locations, continuing anyway: * CAfile: /etc/opt/webstack/curl/curlCA CApath: none * SSL connection using DHE-RSA-AES256-SHA * Server certificate: * subject: C=CA, ST=British Columnbia, L=Vancouver, O=google, OU=FDN, CN=g.googlenet.com, [email protected] * start date: 2007-07-24 23:06:32 GMT * expire date: 2027-09-07 23:06:32 GMT * issuer: C=US, ST=California, L=Sunnyvale, O=Google, OU=Certificate Authority, CN=support, [email protected] * SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway. > POST /gportal/gpmgr HTTP/1.1^M Host: 10.10.101.12^M Accept: */*^M Accept-Encoding: gzip,deflate^M Content-Length: 1623^M Content-Type: application/x-www-form-urlencoded^M Expect: 100-continue^M ^M < HTTP/1.1 100 Continue^M < HTTP/1.1 200 OK^M < Date: Wed, 28 Apr 2010 21:56:15 GMT^M < Server: Apache^M < Cache-Control: no-cache^M < Pragma: no-cache^M < Vary: Accept-Encoding^M < Content-Encoding: gzip^M < Content-Length: 1453^M < Content-Type: application/json^M < ^M * Connection #0 to host 10.10.101.12 left intact * Closing connection #0 My CURL options are as under: $ch = curl_init(); $devnull = fopen('/tmp/curlcookie.txt', 'w'); $fp_err = fopen('/tmp/verbose_file.txt', 'ab+'); fwrite($fp_err, date('Y-m-d H:i:s')."\n\n"); curl_setopt($ch, CURLOPT_STDERR, $devnull); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $desturl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,120); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_VERBOSE,1); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_STDERR, $fp_err); $ret = curl_exec($ch); Anybody has any idea, why it works sometimes but fails mostly? Thanks

    Read the article

  • After resolving and calling host via ipv6 with curl, next ipv4 request fails and vice versa

    - by Ranty
    I need to request the same host with different methods (using IPv4 and IPv6) from the same script. First request is always successful (no matter IPv4 or IPv6), but the second always fails with curl error 45 (Couldn't bind to IP). I'm using the following curl config: function v4_google() { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1'); curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/search?q=Moon'); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_INTERFACE, 'My IPv4 address'); $c = curl_exec($ch); $result = !curl_errno($ch) ? 'Success' : '<b>' . curl_error($ch) . '; #' . curl_errno($ch) . '</b>'; echo '<p>v4_google:<br>Response length: ' . mb_strlen($c) . '<br>Result: ' . $result . '</p>'; curl_close($ch); } function v6_google() { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1'); curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/search?q=Moon'); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); curl_setopt($ch, CURLOPT_INTERFACE, 'My IPv6 address'); $c = curl_exec($ch); $result = !curl_errno($ch) ? 'Success' : '<b>' . curl_error($ch) . '; #' . curl_errno($ch) . '</b>'; echo '<p>v6_google:<br>Response length: ' . mb_strlen($c) . '<br>Result: ' . $result . '</p>'; curl_close($ch); } v6_google(); v4_google(); So long story short, if I query v6_google(); first, then all consecutive calls of v4_google(); are failing with the curl error 45 (Couldn't bind to IP). And vice versa. As you can see, I separated code into different functions and added CURLOPT_FORBID_REUSE and CURLOPT_FRESH_CONNECT plus curl_close($ch), but it didn't help at all. It looks like curl is caching the resolving method of every host you request, and even if you specify another resolving method the next time you call that host, the cached one is used instead. I would appreciate any help with this issue.

    Read the article

  • [c++] upload image to imageshack

    - by cinek1lol
    Hi. I would like to send pictures via a program written in C + + I wrote such a thing using curl.exe WinExec("C:\\curl\\curl.exe -H Expect: -F \"fileupload=@C:\\curl\\ok.jpg\" -F \"xml=yes\" -# \"http://www.imageshack.us/index.php\" -o data.txt -A \"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\" -e \"http://www.imageshack.us\"", NULL); This only works that I would like to send pictures to a variable pre-loaded char (you know what I mean? first reads the pictures into a variable and then send that variable), because now I have to specify the path to the images on disk I wanted to make this program was written in C + + using the curl library, and not the exe. I found it such a program (which some have modified) #include <stdio.h> #include <string.h> #include <iostream> #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> int main(int argc, char *argv[]) { CURL *curl; CURLcode res; struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; struct curl_slist *headerlist=NULL; static const char buf[] = "Expect:"; curl_global_init(CURL_GLOBAL_ALL); /* Fill in the file upload field */ curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "send", CURLFORM_FILE, "nowy.jpg", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "nowy.jpg", CURLFORM_COPYCONTENTS, "nowy.jpg", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "send", CURLFORM_END); curl = curl_easy_init(); headerlist = curl_slist_append(headerlist, buf); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://www.imageshack.us/index.php"); if ( (argc == 2) && (!strcmp(argv[1], "xml=yes")) ) curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); res = curl_easy_perform(curl); curl_easy_cleanup(curl); curl_formfree(formpost); curl_slist_free_all (headerlist); } system("pause"); return 0; } I will be grateful for any help

    Read the article

  • Android page Curl animation

    - by Meymann
    Hi... Two questions: Is there a simple way to do the Curl page flipping animation? A Curl animation is animation of pages flipping, including the page above rolling and the shadows over the lower page. What is the recommended way to do a "gallery" that displays two pages at a time (just like a book)? Is it: Letting the adapter display a linear layout of two images at a time? (it won't let me show a page flipping over the other like a book) Using two pages, placing somehow one near the other, and then when it's time to animate -move the next two pages over? What is the better way that would enable displaying the left page flipping over the right page? Thanks Meymann

    Read the article

  • extract a specific part from a html document , php cURL , php, preg_match

    - by user331071
    Hello ! I'm trying to extract some information from a webpage using php cURL+preg_match or any other function but for some reasons it doesn't work at all . For example from this page http://www.foxtons.co.uk/search?location_ids=1001-29&property_id=712128&search_form=map&search_type=LL&submit_type=search I want to extract the title which is "4 bed house to rent, Caroline Place, Bayswater, W2", the price which is "2,300" and the description which starts at "This fantastic..." and ends at "(Circle and District Lines). " I tried to use php cURL + dom but I'm getting a lot of errors like this "htmlParseEntityRef: expecting ';' in Entity, line: 243" and no result displayed Also I tried to use preg_match or preg_match_all but doesn't work either . A very basic example would be highly appreciated ! thank you !

    Read the article

  • Posting XML via curl (command-line) without using key/value pairs

    - by Mathias Bynens
    Consider a PHP script that outputs all POST data, as follows: <?php var_dump($_POST); ?> The script is located at http://example.com/foo.php. Now, I want to post XML data to it (without using key/value pairs) using command line curl. I have tried many variations of the following: curl -H "Content-type: text/xml; charset=utf-8" --data-urlencode "<foo><bar>bazinga</foo></bar>" http://example.com/foo.php Yet none of them seem to actually post anything — according to the PHP script, $_POST is just an empty array. What am I doing wrong here?

    Read the article

  • PHP4 HTTP Post without cURL

    - by Luke
    I have the following code that works on PHP5 to send a HTTP POST without using cURL. I would like this to work on PHP 4.3.0 and above: $opts = array('http' => array( 'method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Type: application/json\r\n", 'content' => $query ) ); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); HTTP context is only supported on PHP5. Is there anyway to make this work with PHP 4.3.0 - I need a fallback method if PHP5 or cURL is not installed.

    Read the article

  • Advice needed- aweber form submission using curl?

    - by i need help
    Advice needed for backend form submission to aweber and get response. Scenario When customer signup at my form, I will 1. insert the customer details into my own database, 2. send them a welcome email from my system, 3. at the same time I want the email to be added into aweber (this should run in the background, so that customer no need to fill in details for second time) If I use the php curl call alone, is it a good solution? I want to submit form value to aweber, so that aweber add the new email into their system, and then response to my backend script? I have seen many versions outside, which may include: http://scripts.incutio.com/httpclient/ http://freshmeat.net/projects/curl_http_client/ http://snoopy.sourceforge.net/ Are they having any special benefit over the normal php curl call to pass in data?

    Read the article

  • php cURL POST how to follow location

    - by webfac
    Hi Guys, I am in a bit of a rut with a cURL issue. The post works greate, the data is POSTED just fine and received ok, but the url of the posted page never appears in the browser after the cURL session is executed, for example look at the following code: $ch = curl_init("http://localhost/eterniti/cart-step-1.php"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, "error=1&em=$em&fname=$fname&lname=$lname&email1=$email1&email2=$email2&code=$code&area=$area&number=$num&mobile=$mobile&address1=$address1&address2=$address2&address3=$address3&suburb=$suburb&postcode=$postcode&country=$country"); curl_exec($ch); curl_close($ch); The post works fine and I am taken to the cart-step-1.php where I can process the posted data, HOWEVER the location in the URL address bar of the browser remains that of the script page, in this case proc_xxxxxx.php Any ideas how to get the URL address to reflect the page I am actually POSTED to? Thanks a mill

    Read the article

  • getting vbulletin captcha image with curl

    - by ermac2014
    hi I need to download Vbulletin captcha images on my HDD "from vbulletin register page" using curl and PHP. I really need to get samples of captcha images from several VBulletin boards. I'm collecting these samples for research purposes. anyway, here is what I done with curl till now. 1- download register.php page. 2- parse the downloaded page to get captcha image url. 3- download that image. now I have done step 1 and 2 correctly. but in step 3 when I try to download the captcha image I don't get the captcha. I just get either a very tiny blank gif picture. or I get a png picture with vbulletin word on it. I really don't know what i'm doing wrong. I tried to output the html and push it to the browser the image shows correctly. but thats not what I want. I want to download the image and save it on my HDD. here are some codes I've been working on: //get contents with curl function get_content($url) { $theString = parse_url($url); $cookieName = $theString['host']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url."register.php"); curl_setopt($ch, CURLOPT_REFERER, $url."register.php"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)'); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies/cookie.txt"); //saved cookies curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies/cookie.txt"); //saved cookies curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $string = curl_exec ($ch); //print_r(curl_getinfo($ch)); curl_close ($ch); return $string; } //vbulletin main page $url = 'http://blavbulletin.com/'; //get the page $results = get_content($url); if (preg_match_all('/<img[^>]*id\=\"imagereg\"[^>]*src\=\"([^\"]*)\"[^>]*>/s', $results , $captchaimages)) { $captcha = $captchaimages[1][0]; echo "<img src='$url"."$captcha'>"; //when echoed the pic shows correctly //now get the pic $file = get_content("$url"."$captcha"); //save the pic on HDD file_put_contents("captcha.jpg", $file); } any help would be appreciated.. regards,

    Read the article

  • PHP Curl and Loop based on a numeric value

    - by danit
    Im using the Twitter API to collect the number of tweets I've favorited, well to be accurate the total pages of favorited tweets. I use this URL: http://api.twitter.com/1/users/show/username.xml I grab the XML element 'favorites_count' For this example lets assume favorites_count=5 The Twitter API uses this URL to get the favorties: http://twitter.com/favorites.xml (Must be authenticated) You can only get the last 20 favorties using this URL, however you can alter the URL to include a 'page' option by adding: ?page=3 to the end of the favorites URL e.g. http://twitter.com/favorites.xml?page=2 So what I need to do is use CURL (I think) to collect the favorite tweets, but using the URL: http://twitter.com/favorites.xml?page=1 http://twitter.com/favorites.xml?page=2 http://twitter.com/favorites.xml?page=3 http://twitter.com/favorites.xml?page=4 etc... Some kind of loop to visit each URL, and collect the Tweets and then output the cotents. Can anyone help with this: - Need to use CURL to authenticate - Collect the number of pages of tweets (Already scripted this) - Then use a loop to go through each page URL based on the pages value?

    Read the article

  • Re-factoring a CURL request to Ruby's RestClient

    - by user94154
    I'm having trouble translating this CURL request into Ruby using RestClient: system("curl --digest -u #{@user}:#{@pass} '#{@endpoint}/#{id}' --form image_file=@'#{path}' -X PUT") I keep getting 400 Bad Request errors. As far as I can tell, the request does get properly authenticated, but hangs up from the file upload part. Here are my best attempts, all of which get me those 400 errors: resource = RestClient::Resource.new "#{@endpoint}/#{id}", @user, @pass #attempt 1 resource.put :image_file => File.new(path, 'rb'), :content_type => 'image/jpg' #attempt 2 resource.put File.read(path), :content_type => 'image/jpg' #attempt 3 resource.put File.open(path) {|f| f.read}, :content_type => 'image/jpg'

    Read the article

  • Escaping CURL @ symbol with PHP

    - by bkildow
    I'm writing a php application that submits via curl data to sign up for an iContact email list. However I keep getting an invalid email address error. I think this may be due to the fact that I'm escaping the @ symbol so it looks like %40 instead of @. Also, according to the php documentation for curl_setopt with CURLOPT_POSTFIELDS: The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. So, is there anyway to pass the @ symbol as post data through curl in php without running it through urlencode first?

    Read the article

  • [PHP] Using cURL to download large XML files

    - by ndg
    I'm working with PHP and need to parse a number of fairly large XML files (50-75MB uncompressed). The issue, however, is that these XML files are stored remotely and will need to be downloaded before I can parse them. Having thought about the issue, I think using a system() call in PHP in order to initiate a cURL transfer is probably the best way to avoid timeouts and PHP memory limits. Has anyone done anything like this before? Specifically, what should I pass to cURL to download the remote file and ensure it's saved to a local folder of my choice?

    Read the article

  • recaptcha image and curl + php

    - by user253530
    $page = $curl->post($baseUrl.'/submit.php', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1')); $exp = explode('recaptcha_image',$page); The id recaptcha_image is not found although if i echo $page; the webpage will be displayed and surprisingly even the recpatcha div (with the image itself). Curl shouldn't load the image for recaptcha but somehow it does though when i try to find the div, it is not there. Is there a way to capture the url of the recaptcha image?

    Read the article

  • Upload image using CURL + PHP via remote form

    - by user253530
    I have a few images that i need to upload using an online form. So far here's my code $info = array('test title','1234','virginia','@'.realpath('e:\wamp\www\1.jpg'),'@'.realpath('e:\wamp\www\2.jpg'),'@'.realpath('e:\wamp\www\3.jpg'),'@'.realpath('e:\wamp\www\4.jpg'),'test description'); $post->postAd($url, $info); The $info array is processed in the postAd method and it's being sent as an associative array using a method from a Curl class i have (it has been tested and worked nicely with everything i needed to do so far with curl). The problem is that the data is completed correctly on the form but the images are not uploaded. Can anyone help with advices/code/guidance?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >