Search Results

Search found 1194 results on 48 pages for 'curl'.

Page 12/48 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • php cURL. preg_match , extract text from xhtml

    - by Michael
    I'm trying to extract the price from the bellow html page/link using php cURL and preg_match . Basically I'm expecting for this code to output 4,550 but for some reasons I get Notice: Undefined offset: 1 in C:\wamp\www\test.php on line 22 I think that the pattern is correct because if I put the html itself in a variable and escape the "" it works ! . Also if I output (echo $result;) it displays the html properly grabbed from foxtons website so I just can't figure it out why the whole thing doesn't work . I need to make this work and also I would appreciate if you would tell me why is that notice generated and why my current script doesn't work. $url = "http://www.foxtons.co.uk/search?bedrooms_from=0&property_id=727717"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_exec($ch); curl_close($ch); $result2 = str_replace('"', '\"', $result); $tagname1= ");<\/script "; $tagname2= "<\/noscript per month<\/a"; $pattern = "/$tagname1(.*?)$tagname2/"; preg_match($pattern, $result, $matches); $prices = $matches[1]; print_r($prices); ?

    Read the article

  • PHP curl post to login to wordpress

    - by Sadi
    I followed http://stackoverflow.com/questions/724107 to login to wordpress, using php_curl, and it works fine as far I use WAMP, (apache/php). But when it comes to IIS on the dedicated server, it returns nothing. I have wrote the following function which is working fine on my local wamp, but when deployed to client's dedicated windows server 2k3, it doesn't. Please help me function post_url($url, array $query_string) { //$url = http://myhost.com/wptc/sys/wp/wp-login.php /* $query_string = array( 'log'=>'admin', 'pwd'=>'test', 'redirect_to'=>'http://google.com', 'wp-submit'=>'Log%20In', 'testcookie'=>1 ); */ //temp_dir is defined as folder = path/to/a/folder $cookie= temp_dir."cookie.txt"; $c = curl_init($url); if (count($query_string)) { curl_setopt ($c, CURLOPT_POSTFIELDS, http_build_query( $query_string ) ); } curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie); //curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 1); //curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($c, CURLOPT_TIMEOUT, 60); curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); //return the content curl_setopt($c, CURLOPT_COOKIEJAR, $cookie); //curl_setopt($c, CURLOPT_AUTOREFERER, 1); //curl_setopt($c, CURLOPT_REFERER, wp_admin_url); //curl_setopt($c, CURLOPT_MAXREDIRS, 10); curl_setopt($c, CURLOPT_HEADER, 0); //curl_setopt($c, CURLOPT_CRLF, 1); try { $result = curl_exec($c); } catch (Exception $e) { $result = 'error'; } curl_close ($c); return $result; //it return nothing (empty) } Other Facts curl_error($c); return nothing when header CURLOPT_HEADER is set to ON, it return this header HTTP/1.1 200 OK Cache-Control: no-cache, must-revalidate, max-age=0 Pragma: no-cache Content-Type: text/html; charset=UTF-8 Expires: Wed, 11 Jan 1984 05:00:00 GMT Last-Modified: Thu, 06 May 2010 21:06:30 GMT Server: Microsoft-IIS/7.0 X-Powered-By: PHP/5.2.13 Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/wptc/sys/wp/ Set-Cookie: wordpress_b13661ceb5c3eba8b42d383be885d372=admin%7C1273352790%7C7d8ddfb6b1c0875c37c1805ab98f1e7b; path=/wptc/sys/wp/wp-content/plugins; httponly Set-Cookie: wordpress_b13661ceb5c3eba8b42d383be885d372=admin%7C1273352790%7C7d8ddfb6b1c0875c37c1805ab98f1e7b; path=/wptc/sys/wp/wp-admin; httponly Set-Cookie: wordpress_logged_in_b13661ceb5c3eba8b42d383be885d372=admin%7C1273352790%7Cb90825fb4a7d5da9b5dc4d99b4e06049; path=/wptc/sys/wp/; httponly Refresh: 0;url=http://myhost.com/wptc/sys/wp/wp-admin/ X-Powered-By: ASP.NET Date: Thu, 06 May 2010 21:06:30 GMT Content-Length: 0 CURL version info: Array ( [version_number] = 463872 [age] = 3 [features] = 2717 [ssl_version_number] = 0 [version] = 7.20.0 [host] = i386-pc-win32 [ssl_version] = OpenSSL/0.9.8k [libz_version] = 1.2.3 [protocols] = Array ( [0] = dict [1] = file [2] = ftp [3] = ftps [4] = http [5] = https [6] = imap [7] = imaps [8] = ldap [9] = pop3 [10] = pop3s [11] = rtsp [12] = smtp [13] = smtps [14] = telnet [15] = tftp ) ) PHP Version 5.2.13 Windows Server 2K3 IIS 7 Working fine on Apache, PHP 3.0 on my localhost (windows)

    Read the article

  • php curl http 405 error mind body online api

    - by K_G
    I am trying to connect to the Mind Body Online API (their forum is down currently, so I came here). Below is the code I am using. I am receiving this: SERVER ERROR 405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt to access. code: //Data, connection, auth $soapUrl = "http://clients.mindbodyonline.com/api/0_5"; // xml post structure $xml_post_string = '<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://clients.mindbodyonline.com/api/0_5"> <soapenv:Header/> <soapenv:Body> <GetClasses> <Request> <SourceCredentials> <SourceName>username</SourceName> <Password>password</Password> <SiteIDs> <int>site id</int> </SiteIDs> </SourceCredentials> <UserCredentials> <Username>username</Username> <Password>password</Password> <SiteIDs> <int></int> </SiteIDs> </UserCredentials> <Fields> <string>Classes.Resource</string> </Fields> <XMLDetail>Basic</XMLDetail> <PageSize>10</PageSize> <CurrentPageIndex>0</CurrentPageIndex> </Request> </GetClasses> </soapenv:Body> </soapenv:Envelope>'; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: http://clients.mindbodyonline.com/api/0_5", "Content-length: ".strlen($xml_post_string), ); //SOAPAction: your op URL $url = $soapUrl; // PHP cURL for https connection with auth $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // converting $response = curl_exec($ch); curl_close($ch); var_dump($response); // converting //$response1 = str_replace("<soap:Body>","",$response); //$response2 = str_replace("</soap:Body>","",$response1); // convertingc to XML //$parser = simplexml_load_string($response2); // user $parser to get your data out of XML response and to display it. Any help would be great and if anyone has any experience working with their API, my first time ;) Here is the post on stack I am going off of: SOAP request in PHP

    Read the article

  • How can I use curl to login multiple users from one php script

    - by kamal
    Here is the scenario: I have configured multiple users with login names aa1, aa2 .. zz99 , all with the same password, now i want to login to a php based server with these login ID's. I have a working script that logs in one user with a username and password, and using curl, browses to a target page: // Assume php , since somehow the php encapsulation quotes were giving me trouble $sHost = $argv[2]; $sStart = $argv[3]; $sReqId = $argv[4]; $sPage = $argv[5]; $sReqLogFile = $argv[6]; $sRespLogFile = $argv[7]; $sUserName = $argv[8]; $sPassword = $argv[9]; $sExecDelay = $argv[10]; //optional args: if($argc 11) { $sCommonSID = $argv[11]; } //$sXhprofLogFile = ""; $sSysStatsLogFile= ""; $sBaseUrl = 'https://'.$sHost.'/'; $nExecTime = 0; $sCookieFileName = 'cookiejar/'.genRandomString().'.txt'; touch($sCookieFileName); // Set the execution delay: $sStart += $sExecDelay; // Get the PHP Session Id: if(isset($sCommonSID)) { $sSID = $sCommonSID; }else{ $sSID = getSID($sHost,$sBaseUrl, $sUserName, $sPassword); } // Sleep for 100us intervals until we reach the stated execution time: do { usleep(100); }while(getFullMicrotime()$sPage, "pageUrl"=$sBaseUrl, "execStart" =$nExecStart, "execEnd"=$nExecEnd, "respTime"=$nExecTime, "xhprofToken"=$sXhpToken, "xhprofLink"=$sXhpLink, "fiveMinLoad"=$nFiveMinLoad); }else{ $nExecStart = 0; $sUrl = "***ERROR***"; $aReturn = null; } writeReqLog($sReqId, $nExecStart, $sSID, $sUrl, $sReqLogFile); return $aReturn; } function getFullMicrotime() { $fMtime = microtime(true); if(strpos($fMtime, ' ') !== false) { list($nUsec, $nSec) = explode(' ', $fMtime); return $nSec + $nUsec; } return $fMtime; } function writeRespLog($nReqId, $sHost, $sPage, $sSID = "***ERROR***", $nExecStart = 0, $nExecEnd = 0, $nRespTime = 0, $sXhpToken = "", $sXhpLink = "", $nFiveMinLoad = 0, $sRespLogFile) { $sMsg = $nReqId; $sMsg .= "\t".$sHost; $sMsg .= "/".$sPage; $sMsg .= "\t".$sSID; $sMsg .= "\t".$nExecStart; $sMsg .= "\t".$nExecEnd; $sMsg .= "\t".$nRespTime; $sMsg .= "\t".$sXhpToken; $sMsg .= "\t".$nFiveMinLoad; error_log($sMsg."\n",3,$sRespLogFile); } function writeReqLog($nReqId, $nExecStart, $sSID, $sUrl, $sReqLogFile) { $sMsg = $nReqId; $sMsg .= "\t".$sUrl; $sMsg .= "\t".$sSID; $sMsg .= "\t".$nExecStart; error_log($sMsg."\n",3,$sReqLogFile); } function parseSIDValue($sText) { $sSID = ""; preg_match('/SID:(.*)/',$sText, $aSID); if (count($aSID)) { $sSID = $aSID[1]; } return $sSID; } function parseFiveMinLoad($sText) { $nLoad = 0; $aMatch = array(); preg_match('/--5-MIN-LOAD:(.*)--/',$sText, $aMatch); if (count($aMatch)) { $nLoad = $aMatch[1]; } return $nLoad; } function curlRequest($sUrl, $sSID="") { global $sCookieFileName; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $sUrl); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); if($sSID == "") { curl_setopt($ch, CURLOPT_COOKIEJAR, $sCookieFileName); } else { curl_setopt($ch, CURLOPT_COOKIEFILE, $sCookieFileName); } $result =curl_exec ($ch); curl_close ($ch); return $result; } function parseXHProfToken($sPageContent) { //https://ktest.server.net/xhprof/xhprof_html/index.php?run=4d004b280a990&source=mybox $sToken = ""; $sRelLink = ""; $aMatch = array(); $aResp = array(); preg_match('/$sToken, "relLink"=$sRelLink); return $aResp; } function genRandomString() { $length = 10; $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; $string = ''; for ($p = 0; $p

    Read the article

  • Compiling libcurl for mingw32 (Windows) on mac os x 10.6

    - by Daniel
    Hello. I'm compiling libcurl for mingw32 as follows: ./configure --prefix=/Users/daniel/mingw32 "CFLAGS= -ABI=32" make make install But when compiling a program using mingw32-gcc: i386-mingw32-gcc -lcurl -o bin/remote-win.exe remote.c i get: In file included from /Users/daniel/mingw32/usr/local/include/curl/curl.h:34, from remote.c:6: /Users/daniel/mingw32/usr/local/include/curl/curlbuild.h:152:26: sys/socket.h: No such file or directory In file included from /Users/daniel/mingw32/usr/local/include/curl/curl.h:34, from remote.c:6: /Users/daniel/mingw32/usr/local/include/curl/curlbuild.h:165: error: syntax error before "curl_socklen_t" In file included from /Users/daniel/mingw32/usr/local/include/curl/curl.h:35, from remote.c:6: /Users/daniel/mingw32/usr/local/include/curl/curlrules.h:143: error: size of array `__curl_rule_01__' is negative /Users/daniel/mingw32/usr/local/include/curl/curlrules.h:153: error: size of array `__curl_rule_02__' is negative I'm pretty sure the error is because curl_socklen_t does not exist on windows. I've tried --target=--mingw32 but still no success. Please help

    Read the article

  • PHP Curl's Proxy feature causes no information to be returned

    - by Grant David Bachman
    I'm working on a PHP script right now which sends requests to our school's servers to get real-time information about class sizes for different courses. The script runs perfectly fine when I don't use a proxy, returning a string full of course numbers and available seats. However, I want to make this a service for the students, and I'm afraid that if I make too many requests my ip will get blocked. So I'm attempting to do this through a proxy, with no success. As soon as I add the CURLOPT_HTTPPROXYTUNNEL and CURLOPT_PROXY fields to my requests nothing gets returned. I'm not even sure how to troubleshoot it at this point since I'm not getting an error message of any kind. Does anyone know what's going on or how to at least troubleshoot it?

    Read the article

  • Posting a textarea form with cURL

    - by Joey
    How would I go about posting a textarea form? <form method="post" action="/user/test/shoutbox/add" id="shoutPost" class="clearit"> <input name="formtoken" type="hidden" value="852f8fde54190fa5f9aa47172d492f829c1b"/> <input type="hidden" name="backto" value="/user/text/shoutbox" /> <textarea id="shoutmsg" name="message"></textarea> <input type="submit" name="submit" class="confirmButton" value="Post" id="sbPost" /> This should work right? curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_POST, 1); $postfields .= "&message=".$msg; $postfields .= "&submit=sbPost"; curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); $page = curl_exec($ch); but it's not posting for some reason...

    Read the article

  • PHP CURL Google Calendar using Private URL

    - by MooCow
    I'm trying to get an array of events from Google Calendar using the Private URL. I read the Google API document but I want to try doing this without using the ZEND library since I have no idea what the eventual server file structure is and avoid having other people edit the codes. I also did a search before posting and ran into the same condition where PHP CURL_EXEC returns false with the URL but I get a JSON file if the URL is open using a web browser. Since I'm using the Private URL, do I really need to authenticate against the Google server using ZEND? I'm trying to have PHP clean up the array before encoding it for Flash. $URL = <string of the private URL from Google Calendar> $ch = curl_init($URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); $result = json_decode($data); print '<pre>'.var_export($data,1).'</pre>'; Screen output >>> false

    Read the article

  • How to send HTTP get method with headers using CURL

    - by mithunmo
    Hello , I need to send GET Request method with the below headers . I am getting the following capture from HTTP live headers ***http://172.20.22.26/ GET / HTTP/1.1 Host: 172.20.22.26 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Authorization: Basic bWl0aHVuOm1pdGh1bg== HTTP/1.x 200 OK Date: Thu, 01 Jan 2009 00:29:20 GMT Server: HTTPsrv Connection: Keep-Alive Keep-Alive: timeout=30, max=100 Transfer-Encoding: chunked Content-Type: text/html ----------------------------**------------------------------* I am using the following program . It is not working . Please let me know where I am going wrong. <?php $credentials = "mithun:mithun"; $url = "http://172.20.22.26"; $headers = array( "GET /HTTP/1.1", "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1", "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language: en-us,en;q=0.5", "Accept-Encoding: gzip,deflate", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive: 300", "Connection: keep-alive", "Authorization: Basic " . base64_encode($credentials)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); $data = curl_exec($ch); if (curl_errno($ch)) { print "Error: " . curl_error($ch); } else { // Show me the result var_dump($data); curl_close($ch); }?>

    Read the article

  • Extract paragraphs from Wikipedia API using PHP cURL

    - by Kane
    Here's what I'm trying to do using the Wikipedia (MediaWiki) API - http://en.wikipedia.org/w/api.php Do a GET on http://en.wikipedia.org/w/api.php?format=xml&action=opensearch&search=[keyword] to retrieve a list of suggested pages for the keyword Loop through each suggested page using a GET on http://en.wikipedia.org/w/api.php?format=json&action=query&export&titles=[page title] Extract any paragraphs found on the page into an array Do something with the array I'm stuck on #3. I can see a bunch of JSON data that includes "\n\n" between paragraphs, but for some reason the PHP explode() function doesn't work. Essentially I just want to grab the "meat" of each Wikipedia page (not titles or any formatting, just the content) and break it by paragraph into an array. Any ideas? Thanks!

    Read the article

  • Curl redirect,, not working?

    - by Sushant Panigrahi
    I'm using the following code: $agent= 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_URL, "www.example.com"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $output = curl_exec($ch); echo $output; But it redirects to like this: http://localhost/aide.do?sht=_aide_cookies_ Instead of to the URL page. Can anyone help me solve my problem, please?

    Read the article

  • curl follow location error

    - by embedded
    Hi, I got this error message: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in. safe_mode is turned off on my web hosting. open_basedir is "". How do I resolve this? Thanks

    Read the article

  • trying to grab data from a page after post via curl

    - by Ben
    i am trying to grab data from here : http://mediaforest.biz/mobile/nowplaying.aspx in the page you select a station and post it then you get new page with data. but i cant grab it, i get the same page again. i used this code: <?php header ('Content-type: text/html; charset=utf-8'); $url = "http://mediaforest.biz/mobile/nowplaying.aspx"; $referer = ""; // headers $header[] = "Host: ".parse_url($url, PHP_URL_HOST); $header[] = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"; $header[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; $header[] = "Accept-Language: he,en-us;q=0.7,en;q=0.3"; $header[] = "Accept-Encoding: gzip,deflate"; $header[] = "Accept-Charset: windows-1255,utf-8;q=0.7,*;q=0.7"; $header[] = "Keep-Alive: 115"; $header[] = "Connection: keep-alive"; $cookie="cookie.txt"; $fp=fopen($cookie,"w+"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_REFERER,$referer); curl_setopt($ch, CURLOPT_TIMEOUT, 900); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_HEADER,true); curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie); curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie); curl_setopt($ch, CURLOPT_VERBOSE, 0); $content=curl_exec($ch); echo $content; if(stristr($content,"__EVENTTARGET")){ $array1=explode('__EVENTTARGET" value="',$content); $content1=$array1[1]; $array2=explode('"> <input type="hidden" name="__EVENTARGUMENT"',$content1); $content2=$array2[0]; $EVENTTARGET=urlencode($content2); } if(stristr($content,"__EVENTARGUMENT")){ $array1=explode('__EVENTARGUMENT" value="',$content); $content1=$array1[1]; $array2=explode('"> <script language',$content1); $content2=$array2[0]; $EVENTARGUMENT=urlencode($content2); } if(stristr($content,"formNowPlaying")){ $array1=explode('method="post" action="',$content); $content1=$array1[1]; $array2=explode('"> <input type="hidden" name="__EVENTTARGET"',$content1); $content2=$array2[0]; $nexturl=$content2; } //echo $EVENTTARGET." ".$EVENTARGUMENT." ".$nexturl; $url = "http://mediaforest.biz/mobile/".$nexturl; $fields = "EVENTTARGET=".$EVENTTARGET."&__EVENTARGUMENT=".$EVENTARGUMENT."&MyChannels=0&ViewChannel_Button=Show"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_REFERER,$referer); curl_setopt($ch, CURLOPT_TIMEOUT, 900); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_HEADER,true); curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie); curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie); curl_setopt($ch, CURLOPT_VERBOSE, 1); $content_stage2=curl_exec($ch); echo $content_stage2; ?>

    Read the article

  • Get usable array from a curl response, which is formatted as a php array

    - by Mint
    $ch = curl_init("url"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "test"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $outputArray = curl_exec($ch); Then $outputArray will contain: Array ( [0] => Array ( [r1] => test response [r2] => 4 [r3] => 32 ) ) So I would think PHP can see that it's an array and treat it as such, but when I do something like echo $outputCode[0][r_title]."\n"; it gives an error: PHP Fatal error: Cannot use string offset as an array in /www/test.php on line 75 (line 75 being the echo one just above) What am I doing wrong?

    Read the article

  • php curl post parameters not passed to server

    - by user121196
    <?php $data = array('name' => 'Ross', 'php_master' => true); $url="http://localhost/test.php"; $handle = curl_init($url); curl_setopt($handle, CURLOPT_POST, true); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); curl_exec($handle); ?> the $_POST variable on server side is empty, I also tried using java servlet, request.getParameterNames() is also empty. why are the post parameters lost?

    Read the article

  • PHP- Curl Download Bandwidth Limiting

    - by snikolov
    Hey guys, I have been trying to limit the bandwidth with PHP. Can you please help here? I can't get the download rate to be limited with PHP. Thanks a million! function total_filesize($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$url"); curl_setopt($ch, CURLINFO_SPEED_DOWNLOAD,12); //ITS NOT WORKING! curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) ". "Gecko/20071127 Firefox/2.0.0.11"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_NOBODY, true); $chStore = curl_exec($ch); $chError = curl_error($ch); $chInfo = curl_getinfo($ch); curl_close($ch); return $size = $chInfo['download_content_length']; } function __define_url($url) { $basename = basename($url); Define('filename',$basename); $define_file_size = total_filesize($url); Define('filesizes',$define_file_size); } function _download_file($url_file) { __define_url($url_file); // $range = "50000-60000"; $filesize = filesizes; $file = filename; header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$file.'"'); header('Content-Transfer-Encoding: binary'); header("Content-Length: $filesize"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"$url_file"); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); // curl_setopt($ch, CURLOPT_RANGE,$range); curl_exec($ch); curl_close($ch); } _download_file('http://rarlabs.com/rar/wrar393.exe');

    Read the article

  • cURL PHP Proper SSL between private servers with self-signed certificate

    - by PolishHurricane
    I originally had a connection between my 2 servers running with CURLOPT_SSL_VERIFYPEER set to "false" with no Common Name in the SSL cert to avoid errors. The following is the client code that connected to the server with the certificate: curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); However, I recently changed this code (set it to true) and specified the computers certificate in PEM format. curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); curl_setopt($ch,CURLOPT_CAINFO,getcwd().'/includes/hostcert/Hostname.crt'); This worked great on the local network from a test machine, as the certificate is signed with it's hostname for a CN. How can I setup the PHP code so it only trusts the hostname computer and maintains a secure connection. I'm well aware you can just set CURLOPT_SSL_VERIFYHOST to "0" or "1" and CURLOPT_SSL_VERIFYPEER to "false", but these are not valid solutions as they break the SSL security.

    Read the article

  • Saving a remote image with cURL?

    - by thebluefox
    Morning all, Theres a few questions around this but none that really answer my question, as far as I ca understand. Basically I have a GD script that deals with resizing and caching images on our server, but I need to do the same with images stored on a remote server. So, I'm wanting to save the image locally, then resize and display it as normal. I've got this far... $file_name_array = explode('/', $filename); $file_name_array_r = array_reverse($file_name_array); $save_to = 'system/cache/remote/'.$file_name_array_r[1].'-'.$file_name_array_r[0]; $ch = curl_init($filename); $fp = fopen($save_to, "wb"); // set URL and other appropriate options $options = array(CURLOPT_FILE => $fp, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough) curl_setopt_array($ch, $options); curl_exec($ch); curl_close($ch); fclose($fp); This creates the image file, but does not copy it accross? Am I missing the point? Cheers guys.

    Read the article

  • PHP: Post ASPX form that uses 'WebForm_DoPostBackWithOptions' with cUrl

    - by Oliver Cooper
    I am trying to post an ASPX form which uses SharePoint with PHP. Posting data works with standard forms, I just can't seem to get this form working. I did notice an onclick attribute on the submit button: onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$PlaceHolderMain$btnSaveTask", "", true, "", "", false, false))" I have never used ASPX and have no idea what this is. It is not an authentication problem or something wrong with the url as it returns the webpage (which contains the form) fine. Here is my PHP code: function add($username, $password){ $data = array( 'ctl00$PlaceHolderSearchArea$ctl01$ctl00' => 'https://keystone.stpeters.sa.edu.au', 'ctl00$PlaceHolderSearchArea$ctl01$ctl04' => '0', 'ctl00$PlaceHolderMain$DateStart$DateStartDate' => '9/05/2012', 'ctl00$PlaceHolderMain$DateDue$DateDueDate' => '10/05/2012', 'ctl00$PlaceHolderMain$Title' => 'test again', 'ctl00$PlaceHolderMain$btnSaveTask' => 'OK', '__spText1' => '', '__spText2' => '' ); $curl_handle = curl_init(); $fullurl = "https://keystone.stpeters.sa.edu.au/_layouts/StPeters.Keystone/MyTasks/MyTaskDetail.aspx?id=0&IsDlg=1"; // $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 0); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_URL, $fullurl); $returned = curl_exec($ch); curl_close ($ch); return $returned; }

    Read the article

  • Weird behavior of curl and facebook

    - by monthon1
    Here is the code: $ch = curl_init( 'https://graph.facebook.com/btaylor'); curl_setopt( $ch, CURLOPT_USERAGENT, '' ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER ,true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); print_r( $data) ; curl_close($ch); It shows few informations from facebook. It works on my localhost, but when I try to run it on my server it just doesn't work, returns a blank site. I tried to use this code with others sites like example.com and It works, so I thought, that its becouse of facebook blocks my ip (i dont know why it would be true), so I checked it. I have run it with curl_setopt($ch, CURLOPT_PROXY, 'myproxy'); But it still doesn't show any information. I am trying to fix it all day, but its to difficult. Have you got some ideas?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >