Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.php > #4164

Re: curl Shell-Parameter vs. CURLOPT-Konstanten

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups de.comp.lang.php
Subject Re: curl Shell-Parameter vs. CURLOPT-Konstanten
Date 2017-07-13 16:37 +0200
Organization PointedEars Software (PES)
Message-ID <10876584.O9o76ZdvQC@PointedEars.de> (permalink)
References (1 earlier) <1981390.3ZeAukHxDK@PointedEars.de> <ojrgak$ugn$1@dont-email.me> <2386485.mvXUDI8C0e@PointedEars.de> <ok2fkb$jao$1@dont-email.me> <2392003.mvXUDI8C0e@PointedEars.de>

Show all headers | View raw


Thomas 'PointedEars' Lahn wrote:

> […]  Man sollte[tm] wohl besser einen Konverter schreiben, der
> “curl -- libcurl -” verwendet und das Ergebnis von C nach PHP konvertiert.  
> Im Prinzip braucht man dafür nur ein paar reguläre Ausdrücke.

Quickhack mit GNU sed:

#--------------------------------------------------------------------------
curl -L foo --libcurl - |
sed '
  1,/curl_easy_init/d;
  s/^\([[:space:]]*\)curl_easy_setopt(\([^,]\+\), CURLOPT_URL, \("[^"]\+"\));/<?php\n\1$\2 = curl_init(\3);/;
  s/curl_easy_/curl_/g;
  s/\(curl_setopt(\)\([^,]\+\)/\1$\2/;
  s/\(, [0-9]\+\)L/\1/; s/, ([^)]\+)/, /;
  s/^\([[:space:]]*\)\([0-9a-zA-Z]\+\)[[:space:]]*=[[:space:]]*\(.\+\)/\1$\2 = \3/;
  s/curl_perform(/curl_exec($/;
  s/curl_cleanup(/curl_close($/;
  /return/,$d
' |
php -d error_reporting=E_ALL
#--------------------------------------------------------------------------

compiliert.

Die Konstante CURL_HTTP_VERSION_2TLS gibt es in PHP-curl nicht;
die entsprechende Zeile lässt man dann einfach weg, da PHP-curl
automatisch die richtige (sicherste) Protokollversion auswählt.
Andernfalls erhält man eine PHP-Warnung (ausser man setzt
error_reporting entsprechend).

> >> Die Frage an Google nach "php curl redirect" allerdings schon.
> 
> Kommt darauf an.
>  
>> Nichts für ungut,

Alles wird gut :)

-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to de.comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

curl Shell-Parameter vs. CURLOPT-Konstanten Ralph Stahl <post@rstahl.de> - 2017-07-05 13:15 +0200
  Re: curl Shell-Parameter vs. CURLOPT-Konstanten Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-07-06 12:20 +0200
    Re: curl Shell-Parameter vs. CURLOPT-Konstanten Ralph Stahl <post@rstahl.de> - 2017-07-08 22:50 +0200
      Re: curl Shell-Parameter vs. CURLOPT-Konstanten Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-07-09 05:26 +0200
        Re: curl Shell-Parameter vs. CURLOPT-Konstanten Ralph Stahl <post@rstahl.de> - 2017-07-11 14:21 +0200
          Re: curl Shell-Parameter vs. CURLOPT-Konstanten Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-07-13 16:00 +0200
            Re: curl Shell-Parameter vs. CURLOPT-Konstanten Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-07-13 16:37 +0200
              Re: curl Shell-Parameter vs. CURLOPT-Konstanten "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-07-13 18:17 +0200
                Re: curl Shell-Parameter vs. CURLOPT-Konstanten Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-07-17 20:33 +0200

csiph-web