AllSeoHelp.com
Search the Entire Site
  • PHP
  • JavaScript
  • CSS
  • HTML

PHP - Please Help With My Sms App Curl






Topic

Please Help With My Sms App Curl

View Content
Hello, I'm new to lot of this and especially php.

I'm having hard time with one of my app that I created. 
If you go to ticketlawyerorlando.com/sms5.html and you try to send text, (which is set to go to only one number (mine)) than I get error code from php that is supposed to curl it. 


Error:

Warning: curl_setopt() [function.curl-setopt]: Invalid curl configuration option in /home/content/s/j/1/sj10mil/html/ticketlawyerorlando/sms5.php on line 10
SUCCESS


My Html code is :
Code: [Select]
<html>
<body>
<br/>
<form action="sms5.php" method="post">
<b>Your Phone Number:</b> <input type="text" name="to" />
<br/>
<b>Message:</b> <input type="text" name="msg" />
<br/>
<input type="submit" />
</form>
</body>
</html>

My sms5.php code is :
Code: [Select]
<html>
<head>
<title>SMS STATUS</title>
</head>
<body>
<?php
//print $to;
//print $msg;
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_GET,1);
curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?to=3213314633&msg=test4&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,2);
$response = curl_exec($curl_handle);
$code = curl_getinfo($curl_handle,CURLINFO_HTTP_CODE);
//print $code;
//print $response;
print "SUCCESS";
curl_close($curl_handle);
?>
</body>
</html>

In my php, the URL that's being curled, in the part where it says "test4" that should be actual message that  is typed in the form but I don't know what kind of parameter to insert there in order for it to send message that's written, it always sends message "test4".

Please, if you could help me I would greatly appreciate it.

Thank You so much again.


MOD EDIT: code tags added



Similar Tutorials

Curl Loop To Fetch Multiple Pages - Running Curl-multi
Curl
Curl And Ssl
I Don't Get This? Php Curl Dom?
Need Help About Curl
Php & Curl
Curl
Php Curl Help Please
Need Help With Curl In Php
Php/curl
Using Curl
Curl?
Curl
Please Help With My Sms App Curl
Php+curl
Php And Curl..............
Curl
Is Curl The Best Way To Do This?
Curl Help
Curl Connections
Curl And Cookies
Curl Problem
Curl Not Getting Data Right.
Php Curl Proxy
How To Do Curl Authentication?






Curl Loop To Fetch Multiple Pages - Running Curl-multi

Similar Tutorials View Content
good day dear community,

i am workin on a Curl loop to fetch multiple pages:

i have some examples - and a question:

Example: If we want to get information from 3 sites with CURL we can do it like so:


$list[1] = "http://www.example1.com";
$list[2] = "ftp://example.com";
$list[3] = "http://www.example2.com";


After creating the list of links we should initialize the cURL multi handle and adding the cURL handles.


$curlHandle = curl_multi_init();
for ($i = 1;$i <= 3; $i++)
 $curl[$i] = addHandle($curlHandle,$list[$i]);


Now we should execute the cURL multi handle retrive the
content from the sub handles that we added to the cURL multi handle.

ExecHandle($curlHandle);
for ($i = 1;$i <= 3; $i++)
{
 $text[$i] =  curl_multi_getcontent ($curl[$i]);
 echo $text[$i];
}

In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle!

If we want to another Fetch of sites with cURL-Multi - since this is the most pretty way to do it!
Well I am not sure bout the string concatenation. How to do it - Note I want to fetch several hundred pages:
see the some details for this target-server sites - /(I have to create a loop over several hundred sites).

    * siteone.example/?show_subsite=9009
    * siteone.example/?show_subsite=9742
    * siteone.example/?show_subsite=9871

.... and so on and so forth Question: How to appy this loop into the array of the curl-multi?



<?php
/************************************\
* Multi interface in PHP with curl  *
* Requires PHP 5.0, Apache 2.0 and  *
* Curl         *
*************************************
* Writen By Cyborg 19671897         *
* Bugfixed by Jeremy Ellman         *
\***********************************/

$urls = array(
   "siteone",
   "sitetwo",
   "sitethree"
   );

$mh = curl_multi_init();

foreach ($urls as $i => $url) {
       $conn[$i]=curl_init($url);
       curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string 
       curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects
       curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects
       curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout
       curl_multi_add_handle ($mh,$conn[$i]);
}

do { $n=curl_multi_exec($mh,$active); } while ($active);

foreach ($urls as $i => $url) {
       $res[$i]=curl_multi_getcontent($conn[$i]);
       curl_multi_remove_handle($mh,$conn[$i]);
       curl_close($conn[$i]);
}
curl_multi_close($mh);


print_r($res);

?>





I look forward to your ideas.




Curl

Similar Tutorials View Content
What exactly is cURL?

What are alternatives to it?

I am reading some code for submitting payment info to a Payment Gateway and trying to understand how cURL plays into this?!

Thanks,


Debbie



Curl And Ssl

Similar Tutorials View Content
I am using the following code.
Code: [Select]
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);
curl_close($ch);
I was given a .cer file should I set CURLOPT_SSL_VERIFYPEER to TRUE  and set the path to the .cer file?

Any help would be awesome.
Thanks


I Don't Get This? Php Curl Dom?

Similar Tutorials View Content
I have a large list of websites that have allowed me to submit my website and description every 24 hours to there sites. I'm really getting tired of sitting by my computer and submitting the information to every site manually. I never understood curl and php dom stuff. does anyone have a easy code where I can

post a pre scripted text of my information into three boxes and it auto submits every 24 hours to the websites?

The boxes look like this

Code: [Select]
<input maxlength="255" value="http://" name="sPlugurl" size="20" style="font-family: Verdana; color: FE9999; font-size: 10pt; background-color: 656565; font-weight: none; border: 1px solid #0C0C0C" type="text">

<input maxlength="30" value="Sitename" name="sPlugname" size="20" style="font-family: Verdana; color: FE9999; font-size: 10pt; background-color: 656565; font-weight: none; border: 1px solid #0C0C0C" type="text">

<input maxlength="255" value="Description" name="sPlugdescription" size="20" style="font-family: Verdana; color: FE9999; font-size: 10pt; background-color: 656565; font-weight: none; border: 1px solid #0C0C0C" type="text">

<input type="submit" value="Dump" style="background-color: #656565; font-family: Verdana; color: &lt;? echo ;?&gt;; font-size: 10pt; border: 1px solid #0C0C0C">
the php script would auto fill out  the value of the first 3 boxes with my info and then the program would submit it to there forum.

I looked on google but nothing I found I can figure out?


Need Help About Curl

Similar Tutorials View Content
can someone help me create a cURL for this?

i think its a get method, right?

Access it including the GET parameters and make sure that settings are also follows. Dispatcher URL: http://website.net/gw/dispatcher.woof

GET Parameters:
RRN is the random reference number
SRC is the access code (i.e 2336)
DST is the recipient of the message (i.e. 639209547958)
MSG is the actual reply message up to 420 characters, including non printable characters.
KYWRD is the primary keyword (i.e. hello)



need help. thanks..


this is my current code
<?php

//getting the value of RRN
$rrn=urlencode($_GET['rrn']);
//getting the value of MSG
$msg=urlencode($_GET['msg']);
//getting the value of DST
$dst=urlencode($_GET['dst']);
//getting the value of SRC
$src=urlencode($_GET['src']);
//setting up the value of KYWRD
$kywrd = urlencode('KEYWORD');

//assuming that the dst here is 2336

$aw = "haha";


$str= "?src=".$dst."&dst=".$src."&msg=".$aw."&rrn=".$rrn."&kywrd=".$kywrd;

print $str;

 $ch=curl_init();
 curl_setopt($ch,CURLOPT_URL,' http://www.website.net/gw/dispatcher.woof'.$str);
 curl_exec($ch);
 curl_close($ch);


?>

Is this correct? Thanks


Php & Curl

Similar Tutorials View Content
I am trying to send the following curl command using PHP but I have so far been unsuccessful, any help would be appreciated :-)


curl -u 1fd7b89be6f3533d7:X -H  'Content-Type:application/xml' -d '<message><body>Test  using the API</body></message>' http://someurl.com


The purpose of this script is to automatically send a message to a campfire chatroom for a PHPUnit script using Selenium


Curl

Similar Tutorials View Content
Hello
I want download a webpage with curl on my host using php.
but when I use curl didn't download this page, if I change curl to file_get_contents and use it download this page.
please help me to resolve my problem.
URL is : www.ebook33.com
CUL code is :
function Get($url)
{

        $hCurl = curl_init($url);
          curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, TRUE);
          $ret = curl_exec($hCurl);
          curl_close($hCurl);
return ($ret);

File get content code is :
file_get_contents($url);


Php Curl Help Please

Similar Tutorials View Content
I have the following code but i can seem to log into the page can somebody tell me what is wrong please

<?php
error_reporting(E_ALL);
$maindir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
include($maindir.'functions.php');

set_time_limit(0);
ini_set('memory_limit','128M');

$curl_handle = curl_init();
define("SSL_CA_FILE", ".\\temp\\ssl");
define("COOKIE_FILE", "cookies.txt");

$source_file = $maindir.'login_info.txt';
	

// report errores
error_reporting(-1);
	

	
$maindir.'login_info.txt';
	
$fp_s = fopen($source_file, 'r');
	
	

	
$ch = curl_init();

  //curl_followlocation set the curl to follow the site and get the final web page if the
  // website has redirects

	
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)');
	
	
	
	

	
// save cookie
	
curl_setopt($ch, CURLOPT_COOKIEJAR, $maindir.'cookie.txt');

	
// get cookie
	
curl_setopt($ch, CURLOPT_COOKIEFILE, $maindir.'cookie.txt');
	


	
// not to print out the results
	
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	

	
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


	

	
	
$account  = '*****';
	
	
$password = '*****';
	

	
	

	
	
if(file_exists(COOKIE_FILE)) {
	
	
	
unlink(COOKIE_FILE);
	
	
	
}
	
	
	


	
	
$qryString = 'email='.urlencode($account).'&pass='.urlencode($password).'&login_type=1';
	
	

	
	
curl_setopt($ch, CURLOPT_POST, true);
	
	
curl_setopt($ch, CURLOPT_POSTFIELDS, $qryString);
	
	

	
	
curl_setopt($ch, CURLOPT_URL, 'https://secure.gumtree.ie/account/login');
	
	

	
	
$page = curl_exec($ch);
	
	
echo $page;



	
// close session
	
curl_close($ch);
	

?>




Need Help With Curl In Php

Similar Tutorials View Content
Ok, I'm new to this and I don't know much about PHP, much less Curl and how to use the functions inside of PHP:

http://us.php.net/manual/en/book.curl.php

However, I need to do something with this.  I have to create this curl.php file, inside that file I need to take the $_POST array and send it to a different php file... I'm not sure how to do this.  And yes, I only need that.  I'd post the source, but my company's proprietary policies prevent me.


Php/curl

Similar Tutorials View Content
Can anyone help me with setting the content-type with CURL/PHP for file uploads? I've tried all of the common methods, and nothing seems to be working.  For example

Code: [Select]
curl_setopt($session, CURLOPT_HTTPHEADER,array (
        "Content-Type: image/gif",
));

Thanks!


Using Curl

Similar Tutorials View Content
I have a few questions that deals with cURL.

Question #1
Lets say I'm using cURL to fill out a form with multiple pages. Is cURL able to navigate through each page of the form retaining all the previous pages information until I reach the last page, then submit it all without losing any data?

I'm pretty sure this is possible, I just can't seem to find any tutorials or help with it.

Question #2
Lets just say I was trying to fill out a form with a CAPTCHA (which obviously I can't get past). Is there a way to display the web page with all the other information filled out, and just leave the CAPTCHA blank to be manually inputted?

It would be greatly appreciated if you are able to point me in the right direction! Thanks in advance!


Curl?

Similar Tutorials View Content
Hi there,

I wanted to create files from my phpscript. So I used the most obvious function, fopen(). It didn't work on my server and contacted the administrator, who said fopen() was disabled for security reasons, and that I should use cURL. So I did what everyone would do; I googled it. Found the php.net curl manual, but can't really comprehend what it sais. So I have a few questions:

1) Can you create .php files with cURL?
2) How?
3) How do I then write php-content in the file?

Please try to explain rather detailed and simplified, I've never been good at quickly understanding all these things.

Thanks a lot!


Curl

Similar Tutorials View Content
Hi,
 I have server which is posting me these data through curl.
$strPost = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    $strPost .= "<request>";
    $strPost .= "<type>login</type>";
    $strPost .= "<session>21</session>";
    $strPost .= "</request>";
    $url = "http://www.abc.com/xyz.php";
    
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPGET,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, FALSE); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
    if($result == true) {
echo $result;
}
    curl_close($ch);

I wanna read the above xml send i.e $strPost at http://www.abc.com/xyz.php i m trying to read it with $_POST['strPost'] but shows empty.
Can anyone help me.


Please Help With My Sms App Curl

Similar Tutorials View Content
Hello, I'm new to lot of this and especially php.

I'm having hard time with one of my app that I created. 
If you go to ticketlawyerorlando.com/sms5.html and you try to send text, (which is set to go to only one number (mine)) than I get error code from php that is supposed to curl it. 


Error:

Warning: curl_setopt() [function.curl-setopt]: Invalid curl configuration option in /home/content/s/j/1/sj10mil/html/ticketlawyerorlando/sms5.php on line 10
SUCCESS


My Html code is :
Code: [Select]
<html>
<body>
<br/>
<form action="sms5.php" method="post">
<b>Your Phone Number:</b> <input type="text" name="to" />
<br/>
<b>Message:</b> <input type="text" name="msg" />
<br/>
<input type="submit" />
</form>
</body>
</html>

My sms5.php code is :
Code: [Select]
<html>
<head>
<title>SMS STATUS</title>
</head>
<body>
<?php
//print $to;
//print $msg;
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_GET,1);
curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?to=3213314633&msg=test4&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,2);
$response = curl_exec($curl_handle);
$code = curl_getinfo($curl_handle,CURLINFO_HTTP_CODE);
//print $code;
//print $response;
print "SUCCESS";
curl_close($curl_handle);
?>
</body>
</html>

In my php, the URL that's being curled, in the part where it says "test4" that should be actual message that  is typed in the form but I don't know what kind of parameter to insert there in order for it to send message that's written, it always sends message "test4".

Please, if you could help me I would greatly appreciate it.

Thank You so much again.


MOD EDIT: code tags added


Php+curl

Similar Tutorials View Content
hello i`m new here .
i need someone to build a php script with CURL and <iframe>
i can pay for the script
PM back or email me here icemerc@yahoo.com


Php And Curl..............

Similar Tutorials View Content
how to pass data on other domain in PHp or curl ?? and also how to get data on other domain ?? if anyone knows how to do it please attach code


Curl

Similar Tutorials View Content
hy all long time no see
recently i did find this problem
i'm trying to login to a webpage with curl ,but without success ,ofcourse the basic posting is not the problem xD but the page have a hidden field (for security) so everytime you load the page it changes so post wont work if you first use get to take the page and extract the hash from it.

the page contains something like
input type= hidden value=A RANDOM VALUE THAT CHANGES EVERYTIME

without that value passed to post it wont login.

anyone knows how can i pass it so the post will be valid?
thank you


Is Curl The Best Way To Do This?

Similar Tutorials View Content

Curl Help

Similar Tutorials View Content
I have just installed cURL and am learn to use it but I'm not sure exactly what I am doing.  For example I have a page with this code on it. 


if($_GET['number'] == "6") {
    echo("<p>the number is six</p>");
}

Then I am trying to use cURL to send the number 6 to this page so that it returns "the number is 6".  However I am just getting an output of "1".  Below is the code I am using to try to get the output of "the number is 6". 


$ch2 = curl_init();

curl_setopt($ch2,CURLOPT_URL,'http://localhost/crawler/crawlertest.php');
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2,CURLOPT_POSTFIELDS,'number=6');
$return = curl_exec($ch2); 

echo ($return);

curl_close($ch2);


Thanks for any help



Curl Connections

Similar Tutorials View Content
Hi,

I would just like to know what limitations apply for opening X amount of connections to different websites with Curl? (specifically, I'm using Curl multi and have my own way of regulating how many connections occur at a given time).

I ask this because it seems I can open 100 connections and get the info from the websites quite quickly. If I were to open say 1000 would that crash my router or what would happen?

Thanks in advance!


Curl And Cookies

Similar Tutorials View Content
1. I want cURL to use cookies from my browser (i use firefox). So i have the cookies.sqlite file. I'm guessing i can't use that so i used the cookies export extension and now i've got a file like this:

Code: [Select]
.ea.com TRUE / FALSE 1294567511 __utmz 103303007.1278799512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
.ea.com TRUE / FALSE 1341871511 __utma 103303007.1717195267.1278799512.1278799512.1278799512.1
.ea.com TRUE / FALSE 1281477904 displayCountrySelector true

Can the cookie file read a file like this? Or does it need a different syntax?

2. How can i make cURL read those cookies?

P.S. What i want to do is access a site with cURL, but make it read cookies from a file that contains cookies exported from my browser.


Curl Problem

Similar Tutorials View Content
I'm trying to submit to my site using this script that I made:
<?php
session_start();
$title = "<title>CS</title>";
$url =  "http://cheatskape.com/wtag/sendchat.php";
$token = md5(uniqid(rand(), true));
$_SESSION['token'] = $token;
$ch = curl_init(); //Initalize a new cURL session
$name = "PROBLEM";
$msg = "LOL";
$postfields = "token=".$token."&name=".$name."&url=&message=".$msg."";
echo $title; //set the title of the window
curl_setopt($ch, CURLOPT_POST, 1); //set the type,
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); //and what fields to use
curl_setopt($ch, CURLOPT_URL, $url);//Set the URL to use
curl_exec($ch); //execute it
echo "<br /><br /><br />"; 
print_r(curl_getinfo($ch)); //Print info of the cURL execution
curl_close($ch); //Close our current cURL session
?>
However, it refuses to post..

What am I doing wrong? This is my first time using cURL

the curl info shows me this:
Quote

Array ( [url] => http://cheatskape.com/wtag/sendchat.php [content_type] => text/xml; charset=UTF-8 [http_code] => 200 [header_size] => 439 [request_size] => 208 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.39 [namelookup_time] => 0 [connect_time] => 0.188 [pretransfer_time] => 0.188 [size_upload] => 68 [size_download] => 2039 [speed_download] => 5228 [speed_upload] => 174 [download_content_length] => 2039 [upload_content_length] => 0 [starttransfer_time] => 0.39 [redirect_time] => 0 [certinfo] => Array ( ) )




Curl Not Getting Data Right.

Similar Tutorials View Content
I am trying to go to http://lirr42.mta.info/
and get the data from the submitted form. I have rebuilt the form exactly as needed, and done a few adjustments.  The posts that I am sending from MY form, are the same as the one on the site.  This site allows public data mining by the way.  So does someone seem something wrong with my code?

I know the basics are working. I have another page that is working fine. It's just this one ends up returning something..it returns part of the data but it's something wrong with it.

Any advice is appreciated.
Code: [Select]
<?php
define( 'DEBUG', true );

define( 'DEFAULT_STOP', 'Broadway' );

// report all errors during development/debug mode
if ( DEBUG ) 
error_reporting( E_ALL );
else
error_reporting( 0 );

include( 'simplehtmldom/simple_html_dom.php' );

$mta_post_url = 'http://lirr42.mta.info/schedules.php';

// GTFS Specification File Definitions
$gtfs_files = array
(
'agency'          =>  'agency.txt',                  // required
'stops'           =>  'stops.txt',                   // required
'routes'          =>  'routes.txt',                  // required
'trips'           =>  'trips.txt',                   // required
'stop_times'      =>  'stop_times.txt',              // required
'calendar'        =>  'calendar.txt',                // required
'calendar_dates'  =>  'calendar_dates.txt',
'fare_rules'      =>  'fare_rules.txt',
'fare_attributes' =>  'fare_attributes.txt',
'shapes'          =>  'shapes.txt',
'frequencies'     =>  'frequencies.txt',
'transfers'       =>  'transfers.txt'
);

$gtfs_pickup_codes = array
(
    0 => 'Regularly scheduled pickup',
    1 => 'No pickup available',
    2 => 'Must phone agency to arrange pickup',
    3 => 'Must coordinate with driver to arrange pickup'
);

$gtfs_dropoff_codes = array
(
0 => 'Regularly scheduled drop off', 
    1 => 'No drop off available',
    2 => 'Must phone agency to arrange drop off',
    3 => 'Must coordinate with driver to arrange drop off'
);

// load stops file 
$stopsFile = fopen( 'data/lir/' . $gtfs_files[ 'stops' ], "r" );

if ( $stopsFile )
{
// get (and toss) header row
$stopsHeader = fgetcsv( $stopsFile, 1000 );

// print_r( $stopsHeader );

// will hold HTML output for Select dropdown for stops
$stopSelectOptions = '';

// build array from file data
while ( $data = fgetcsv( $stopsFile, 1000 ) )
{
$stopsData[ $data[1] ] = $data[0]; 
}

// get a sorted array of the stop names ( yes this could be done with array_multisort or usort but I didnj't feel like it right now )
$stopNames = array_keys( $stopsData );
sort( $stopNames );

// loop through sorted array and create SELECT options with default SELECTED at Grand Central Terminal
foreach( $stopNames as $stop )
$stopSelectOptions .= sprintf( '<option %s value="%d">%s</option>', ( DEFAULT_STOP == $stop ) ?  'selected="selected"' : '' , $stopsData[ $stop ], $stop ) . "\n\r";
}
fclose( $stopsFile );


// load ads file 
$adsFile = fopen( 'ads.txt', "r" );

if ( $adsFile )
{
// get (and toss) header row
$adsHeader = fgetcsv( $adsFile, 1000 );

// will hold ads available for stops
$ads = array();

// build array from file data
while ( $data = fgetcsv( $adsFile, 1000 ) )
{
$ads[ $data[0] ] = array
(
'filename' => $data[1],
'url'      => $data[2],
'text'     => $data[3]
);
}
fclose( $adsFile );
}


// printout the html header
require_once( 'header.php' );


if ( 'POST' == $_SERVER[ 'REQUEST_METHOD' ] ) 
{
$from_stop = $_POST[ 'FromStation' ];  // @todo Filter! http://www.php.net/manual/en/filter.filters.validate.php
$orig_station = $from_stop;

$to_stop = $_POST[ 'ToStation' ];  // @todo Filter! http://www.php.net/manual/en/filter.filters.validate.php
$dest_station = $to_stop;

if (  $to_stop == $from_stop ) 
{
$error = 'Originating and Destination stops are the same.';
}
else
{

print_ad( $orig_station, $dest_station, $location='top' );

$travel_date = $_POST[ 'RequestDate' ];
$requestTime = $_POST[ 'RequestTime' ];
$am_pm       = $_POST[ 'RequestAMPM' ];
$filter      = $_POST[ 'sortBy' ];

/*
* Lets post this to MTA.info
*/

$mta_curl = curl_init();

$mta_curl_options = array
(
CURLOPT_FAILONERROR    => true,
CURLOPT_FOLLOWLOCATION => false,
// CURLOPT_MUTE           => true,
CURLOPT_POST           => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT        => 30,
CURLOPT_URL            => $mta_post_url,
CURLOPT_REFERER        => 'http://lirr42.mta.info/',
CURLOPT_USERAGENT      => 'MTA Info Scrape/1.0',
CURLOPT_POSTFIELDS     => http_build_query( $_POST )
);
curl_setopt_array( $mta_curl, $mta_curl_options );
$mta_response = curl_exec( $mta_curl );

if ( false === $mta_response )
{
curl_close( $mta_curl );
die( sprintf( 'Response Code:%s, Curl Error No:%s, Curl Error Message:%s', curl_getinfo( $mta_curl, CURLINFO_HTTP_CODE ),curl_errno( $mta_curl ), curl_error( $mta_curl ) ) );
}
else
{
curl_close( $mta_curl );
echo '<pre>' . htmlentities( $mta_response ) . '</pre>';

$html = new simple_html_dom();
$html->load( $mta_response );
$schedule_table = $html->find( 'table', 0 );  // find second table in the response
$row_count = 0;

// will hold HTML output for table
$stopSchedule = '<table><th>Departs</th><th>Arrives</th><th>Minutes</th><th>Transfer</th><th>Fare</th></tr>';

foreach ( $schedule_table->find('tr') as $schedule_row ) 
{
$row_count++;
// check for and skip header row
if ( 1 == $row_count )
continue;

// check for and skip last row which first TD has rowspan attribute
if ( $schedule_row->children(0)->colspan )
{
continue;
}
// extract table data for this row
$depart_time      = $schedule_row->children( 0 )->innertext;
$arrive_time      = $schedule_row->children( 2 )->innertext;
$minutes_traveled = $schedule_row->children( 4 )->innertext;
$transfer         = $schedule_row->children( 5 )->innertext;
$fare             = $schedule_row->children( 6 )->plaintext; 
// add table row to html output
$stopSchedule .= sprintf( '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $depart_time, $arrive_time, $minutes_traveled, $transfer, $fare ) . "\n\r";
}  // end foreach schedule_row

// add table end tag to html output
$stopSchedule .= '</table>';

// output table to browser
echo $stopSchedule;

print_ad( $orig_station, $dest_station, $location='bottom' );

} // end if mta response

} // end if not same orig and dest 

} // end if POST


if ( 'GET' == $_SERVER[ 'REQUEST_METHOD' ] || ! empty( $error ) ) 
{

print_ad( null, null, $location = 'default' );

?>

<form method="post">

<?php

if ( ! empty ( $error ) )
{
echo sprintf( '<div class="error">%s</div>', $error );
}

?>

From:<br />
<select id="orig_station" name="FromStation" tabindex="2">
<?php echo $stopSelectOptions; ?>
</select>

<br />
<br />

To:<br />
<select id="dest_station" name="ToStation" tabindex="3">
<?php echo $stopSelectOptions; ?>
</select>

<br />
<br />

<input id="date1" name="RequestDate" size="12" maxlength="10" tabindex="4" value="<?php echo date( 'm/d/Y' ); ?>" />

<?php 
$currentHour = trim( date( 'h' ) );
$currentMinutes = trim( date( 'i' ) );
$currentMinutesFloor =  sprintf( '%02d' , $currentMinutes - ( $currentMinutes % 30 ) );
$currentAMPM = trim ( date( 'A' ) );

$start_time = strtotime( '1:00 AM' );
$end_time = strtotime( '1:00 PM' );
?>

<select name="RequestTime" tabindex="5">
<?php
while( $start_time < $end_time )
{
$option_time = date( 'h:i', $start_time );
$option_hour = trim( date( 'h', $start_time ) );

$option_minutes = trim( date( 'i', $start_time ) );
$option_selected = (  $option_hour == $currentHour && $option_minutes  == $currentMinutesFloor );

echo sprintf( '<option %s>%s</option>', ( $option_selected ) ? 'selected="selected"' : '',  $option_time ) . "\r\n";

$start_time = $start_time + 30*60;
}
?>
</select>

<select name="RequestAMPM" tabindex="6">

<option value="AM" <?php echo ( 'AM' == $currentAMPM ) ? 'selected="SELECTED"' : ''; ?>>AM</option>
<option value="PM" <?php echo ( 'PM' == $currentAMPM ) ? 'selected="SELECTED"' : ''; ?>>PM</option>
</select>

<input name="sortBy" type="hidden" value="1" />
<input type="submit" name="submit" value="Check Schedule" />
</form>


<!--  images/base/
ic_menu_back.png
ic_menu_home.png

-->
<?php 

}

require_once( 'footer.php' );

?>



Php Curl Proxy

Similar Tutorials View Content
I need a proxy that would enable me to use curl with another ip address.

How do I find a paid proxy server that supports curl?


How To Do Curl Authentication?

Similar Tutorials View Content
Hi, iam working on a curl based authentication and iam sending a curl request to one of my pages, like this:


<?php
$ch = curl_init("http://localhost/test.php");
        
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, 'myuser:mypwd'); 
// sending username and pwd.                   
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);                          
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);                           
curl_setopt($curl, CURLOPT_USERAGENT, 'Sample Code');
curl_setopt($curl, CURLINFO_HEADER_OUT, true);

$output = curl_exec($ch);
print_r(curl_getinfo($ch));      
curl_close($ch);
echo '<br><br>';
echo $output;
?>


But in my test.php page, iam not able to get the username and password values, in $_SERVER array.  What could be the problem? 


Privacy