PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 28th, 2013, 04:12 PM
MikkM MikkM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 MikkM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 m 31 sec
Reputation Power: 0
Post to external site with curl

Hi, i am trying to post something to external site, and i found out best way to do this is cURL.

Here is my code:
PHP Code:
<html>
<
body>
<?
php
include('simple_html_dom.php');
$url "example.com";
$a "744bhz";
$html = new simple_html_dom();
$ch curl_init();
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_FAILONERROR1);
curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
curl_setopt($chCURLOPT_USERAGENT,
        
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_POSTFIELDS'pregnr=' urlencode($a));
$result curl_exec($ch);
echo 
$result;
curl_close($ch);
?>
</body>
</html> 


Problem is it only loads me blank page nothing else, i have error reporting enabled in php.ini, but no errors, just blank page.

Site html is like this:
Code:
<FORM NAME="kindlustuskate" METHOD="POST" ACTION="SYSADM.LK_INFOKESKUS_PKT.kindlustuskate">
<input type="hidden" name="plang" value="ENG">
<TABLE width=100%  CELLPADDING=3 CELLSPACING=0 BORDER=0>
<tr>
               <td align="right" width=350>Registration plate number</td>
               <td  width=10>&nbsp;</td>
               <td><input type="text" name="pregnr" value=""> <font size="1">For example 000XXX</font></td>
            </tr>
<tr>
               <td align="right" width=350>Vehicle VIN code</td>
               <td  width=10>&nbsp;</td>
               <td><input type=text name=pvin value=> <font size=1>For example 45XXXXXXXXXXXXXXXXX65</font></td>
            </tr>
<tr>
               <td align="right" width=350>Insurance policy number</td>
               <td  width=10>&nbsp;</td>
               <td><input type=text name=ppolnr value=""> <font size=1>For Example E0000000T</font></td>
            </tr>
<tr>
               <td align="right" width=350>Date of validity</td>
               <td  width=10>&nbsp;</td>
               <td><input type=text name=pkuup value="">&nbsp;<font size=1>dd.mm.yyyy</font></td>
            </tr>
<tr>
<td align=right valign=top>Area of validity</td>
<td align=right valign=top>&nbsp;</td>
<td align=left valign=middle>
<input type=radio name="pala" checked value="1">European Economic Area (EEA) member state or Switzerland<br>
<input type="radio" name="pala" value="2">Green card system country<br>
</td></tr>
<tr>
               <td align="right" width=350>&nbsp;</td>
               <td  width=10>&nbsp;</td>
               <td><input type="submit" name="potsi" value="Find"></td>
            </tr>
</table>
</form>



Site is https, i dont know if this matters or not, but ihave set sssl verify false in curl anyway.
I have messed with this for many hours, any ideas?

Reply With Quote
  #2  
Old January 28th, 2013, 05:32 PM
ptr2void ptr2void is offline
I haz teh codez!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,476 ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 4 h 42 m 37 sec
Reputation Power: 2194
Why do people just automatically assume every call they makes succeeds without checking?

php Code:
Original - php Code
  1.  
  2. $result = curl_exec($ch);
  3. if ($result === FALSE)
  4. {
  5.     echo ("ERROR: " . curl_error($ch));
  6. }
  7. curl_close($ch)


If the error you're getting is

Code:
ERROR: error:14077417:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert illegal parameter


then add

php Code:
Original - php Code
  1. curl_setopt($ch, CURLOPT_SSLVERSION, 3);
__________________
I ♥ ManiacDan & requinix

This is a sig, and not necessarily a comment on the OP:
Please don't be a help vampire!

Last edited by ptr2void : January 28th, 2013 at 05:35 PM.

Reply With Quote
  #3  
Old January 28th, 2013, 07:18 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 35 m 32 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
And you'll have to pass more than just the license plate number otherwise the form just redisplays itself.

Reply With Quote
  #4  
Old January 29th, 2013, 02:36 AM
MikkM MikkM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 MikkM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 m 31 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
And you'll have to pass more than just the license plate number otherwise the form just redisplays itself.


But in original site i can just input license plate and click submit, why cant i do this with curl?

vs.lkf.ee/pls/xlk/SYSADM.LK_INFOKESKUS_PKT.kindlustuskate

Just add https in front of it, i cant post live links here.

For example 217thd.

Reply With Quote
  #5  
Old January 29th, 2013, 03:19 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 35 m 32 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Because not entering values is not the same as not passing them along at all.

Reply With Quote
  #6  
Old January 29th, 2013, 03:26 AM
donglin2013 donglin2013 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 donglin2013 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
this matters or not

i dont know if this matters or not, but ihave set sssl verify false in curl anyway.

Reply With Quote
  #7  
Old January 29th, 2013, 05:14 AM
MikkM MikkM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 MikkM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 m 31 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
Because not entering values is not the same as not passing them along at all.


But how can i pass empty value with curl, i tried "0" but that wont work. It fills form with 0.

Maybe
PHP Code:
 curl_setopt($chCURLOPT_POSTFIELDS'formname='); 
??

Reply With Quote
  #8  
Old January 29th, 2013, 11:48 AM
MikkM MikkM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 MikkM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 m 31 sec
Reputation Power: 0
I tried with
Code:
 curl_setopt($ch, CURLOPT_POSTFIELDS, 'formname=');  

Nothing, it just loads the site as anything is not submited, anyone have any ideas?

PHP Code:
<html>
<
body>
<?
php
include('simple_html_dom.php');
$url "https://vs.lkf.ee/pls/xlk/SYSADM.LK_INFOKESKUS_PKT.kindlustuskate?plang=EST";
$a "744bhz";
$html = new simple_html_dom();
$ch curl_init();
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_FAILONERROR1);
curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
curl_setopt($chCURLOPT_USERAGENT,
        
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
curl_setopt($chCURLOPT_SSLVERSION3);
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_POSTFIELDS'pregnr=' urlencode($a));
curl_setopt($chCURLOPT_POSTFIELDS'pvin=');
curl_setopt($chCURLOPT_POSTFIELDS'ppolnr=');
curl_setopt($chCURLOPT_POSTFIELDS'pkuup=');
$result curl_exec($ch);
if (
$result === FALSE)
{
    echo (
"ERROR: " curl_error($ch));
}

curl_close($ch);
echo 
$result;
?>
</body>
</html> 

Reply With Quote
  #9  
Old January 29th, 2013, 12:10 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 35 m 32 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
All those curl_setopt()s you have are overwriting each other.

Give it an array of the values you want to send.

Reply With Quote
  #10  
Old January 29th, 2013, 01:03 PM
MikkM MikkM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 MikkM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 m 31 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
All those curl_setopt()s you have are overwriting each other

Give it an array of the values you want to send.


Thanks for the hint, i made an array with values, but i am still not sure if passing empty data is done right, anyway still no success, script still loads site as no data has been entered.

Code with changes:
PHP Code:
<html>
<
body>
<?
php
include('simple_html_dom.php');
$url "https://vs.lkf.ee/pls/xlk/SYSADM.LK_INFOKESKUS_PKT.kindlustuskate?plang=EST";

$data = array('pregnr' => '217thd''pvin' => '''ppolnr' => '''pkuup' => '' );


$html = new simple_html_dom();
$ch curl_init();
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_FAILONERROR1);
curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
curl_setopt($chCURLOPT_USERAGENT,
        
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
curl_setopt($chCURLOPT_SSLVERSION3);
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
curl_setopt($chCURLOPT_POST1);

curl_setopt($chCURLOPT_POSTFIELDS,  $data);


$result curl_exec($ch);
if (
$result === FALSE)
{
    echo (
"ERROR: " curl_error($ch));
}
curl_close($ch);
echo 
$result;
?>
</body>
</html> 


I appreaciate any help , since i am newbie in php

Reply With Quote
  #11  
Old January 29th, 2013, 02:22 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 35 m 32 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
That's right, but you still haven't included all the form fields.

Example: when you click a named submit button, its name and value are included in the request.

Reply With Quote
  #12  
Old January 29th, 2013, 02:38 PM
MikkM MikkM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 MikkM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 m 31 sec
Reputation Power: 0
Thumbs up

[QUOTE=requinix]That's right, but you still haven't included all the form fields.

Example: when you click a named submit button, its name and value are included in the request.[/QUOTE

Ha, i see, thank you very much !!!

Got it working
PHP Code:
 $data = array('plang' => 'EST','pregnr' => '217thd''pvin' => '''ppolnr' => '''pkuup' => '''pala' => '1''potsi' => 'Otsi' ); 

Reply With Quote
  #13  
Old February 6th, 2013, 07:28 AM
gpotm003 gpotm003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 gpotm003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 38 sec
Reputation Power: 0
Thank You mate sincerely so much for this topic!
Was just working with the same god damn insurance data reading issue and struggling with similar error, but You made my life so much easier

Tauno

Quote:
Originally Posted by MikkM
[QUOTE=requinix]That's right, but you still haven't included all the form fields.

Example: when you click a named submit button, its name and value are included in the request.[/QUOTE

Ha, i see, thank you very much !!!

Got it working
PHP Code:
 $data = array('plang' => 'EST','pregnr' => '217thd''pvin' => '''ppolnr' => '''pkuup' => '''pala' => '1''potsi' => 'Otsi' ); 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Post to external site with curl

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap