Jump to content

[SOLVED] cURL/PHP - Outputting Different Data


clookid

Recommended Posts

I would like multiple, different urls / proxy servers / proxy ports to be submitted, all on the same script (without having to create any other files).

 

function file_get_contents_proxy($szURL, $szProxy, $iProxyPort)
{
    $pCurl = curl_init($szURL);
    
    curl_setopt(CURLOPT_PROXY, $szProxy);
    curl_setopt(CURLOPT_PROXYPORT, $iProxyPort);
    
    curl_setopt(CURLOPT_FOLLOWLOCATION, true);
    curl_setopt(CURLOPT_RETURNTRANSFER, true);
    
    return curl_exec($pCurl);
}

$szURL = 'https://clooscript01:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes';
$szProxy = '221.233.134.87';
$iProxyPort = '8080';

file_get_contents_proxy($szURL, $szProxy, $iProxyPort);
file_get_contents_proxy(Output different URL, Output different Proxy, Output different Port);

 

How can I get that to work?

Link to comment
https://forums.phpfreaks.com/topic/70563-solved-curlphp-outputting-different-data/
Share on other sites

  • Replies 70
  • Created
  • Last Reply

Puts the servers into an array then loop through it and execute your function. eg;

 

<?php

  $servers = array(
    array(
      'szURL' => 'https://clooscript01:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
      'szProxy' => '221.233.134.87',
      'iProxyPort' = '8080'
      ),
    array(
      'szURL' => 'https://foo',
      'szProxy' => '203.0.178.145',
      'iProxyPort' = '8080'
      )
  );

  foreach ($servers as $server) {
    file_get_contents_proxy($server['szURL'], $server['szProxy'], $server['iProxyPort']);
  }

?>

<?php

function file_get_contents_proxy($szURL, $szProxy, $iProxyPort)
{
    $pCurl = curl_init($szURL);
    
    curl_setopt(CURLOPT_PROXY, $szProxy);
    curl_setopt(CURLOPT_PROXYPORT, $iProxyPort);
    
    curl_setopt(CURLOPT_FOLLOWLOCATION, true);
    curl_setopt(CURLOPT_RETURNTRANSFER, true);
    
    return curl_exec($pCurl);
}

  $servers = array(
    array(
      'szURL' => 'https://clooscript01:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
      'szProxy' => '221.233.134.87',
      'iProxyPort' = '8080'
      ),
    array(
      'szURL' => 'https://clooscript02:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
      'szProxy' => '202.105.182.13',
      'iProxyPort' = '80'
      )
  );

  foreach ($servers as $server) {
    file_get_contents_proxy($server['szURL'], $server['szProxy'], $server['iProxyPort']);
  }

?>

 

That will work, correct?

http://www.ipsecured.info/test.php

 

Parse error: syntax error, unexpected '=', expecting ')' in /home/ipsecure/public_html/test.php on line 39

Parse error: syntax error, unexpected '=', expecting ')' in /home/ipsecure/public_html/test.php on line 39

 

How do I fix the syntax errors?

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 9

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 10

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 12

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 13

 

Sorry, Authorization Required.

 

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

 

Please check the URL for proper spelling and capitalization. If you're having trouble locating a destination on Yahoo!, try visiting the Yahoo! home page or look through a list of Yahoo!'s online services. Also, you may find what you're looking for if you try searching below. (Loaded ten times)

 

Accessible at: http://www.ipsecured.info/test.php

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 9

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 10

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 12

Warning: Wrong parameter count for curl_setopt() in /home/ipsecure/public_html/test.php on line 13

 

 

Your curl_setopt function is expecting the handle parameter.

Add the handle to the curl_setopt function lke this

 

curl_setopt($pCurl,CURLOPT_PROXY, $szProxy);

 

in all your curl_setopt functions.

 

Now it just loads up a blank page (after about 30 seconds, again, http://www.ipsecured.info/test.php as an example).

 

Below is a copy of the current file. Please let me know what needs changing in order for the script to work. Thank you. :)

 

<?php

function file_get_contents_proxy($szURL, $szProxy, $iProxyPort)
{
$pCurl = curl_init($szURL);
curl_setopt($pCurl, CURLOPT_PROXY, $szProxy);
curl_setopt($pCurl, CURLOPT_PROXYPORT, $iProxyPort);

curl_setopt($pCurl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($pCurl, CURLOPT_RETURNTRANSFER, true);

return curl_exec($pCurl);
}

$password = "mypasswordhere";

$title = "IP Secured";

$url = "http://www.ipsecured.info";
$description = "IP%20Secured";
$note = "IP%20Secured%20--%20you%20no%20longer%20need%20to%20worry%20about%20filters.";
$tags = "ip%20secured,%20proxy";

$servers = array(
array(
'szURL' => 'https://clooscript01:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '192.17.239.250',
'iProxyPort' => '3127'
),
array(
'szURL' => 'https://clooscript02:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '128.8.126.112',
'iProxyPort' => '3124'
),
array(
'szURL' => 'https://clooscript03:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '129.240.67.18',
'iProxyPort' => '3128'
),
array(
'szURL' => 'https://clooscript04:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '212.241.168.184',
'iProxyPort' => '80'
),
array(
'szURL' => 'https://clooscript05:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '156.17.10.52',
'iProxyPort' => '3124'
),
array(
'szURL' => 'https://clooscript06:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '61.16.154.132',
'iProxyPort' => '80'
),
array(
'szURL' => 'https://clooscript07:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '156.17.10.51',
'iProxyPort' => '3124'
),
array(
'szURL' => 'https://clooscript08:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '194.103.159.85',
'iProxyPort' => '80'
),
array(
'szURL' => 'https://clooscript09:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '213.114.118.44',
'iProxyPort' => '8080'
),
array(
'szURL' => 'https://clooscript10:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '67.87.108.252',
'iProxyPort' => '7212'
)
);

foreach ($servers as $server) {
file_get_contents_proxy($server['szURL'], $server['szProxy'], $server['iProxyPort']);
}

echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript01'>clooscript01</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript02'>clooscript02</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript03'>clooscript03</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript04'>clooscript04</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript05'>clooscript05</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript06'>clooscript06</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript07'>clooscript07</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript08'>clooscript08</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript09'>clooscript09</a>.<br />";
echo "<a href='$url' alt='$title'>$title</a> has successfully been submitted to <a href='http://del.icio.us/clooscript10'>clooscript10</a>.<br />";

?>

IP Secured has successfully been submitted to clooscript01.

IP Secured has successfully been submitted to clooscript01.

 

I am unsure is to why that is appearing twice. Nevertheless, it has not made the submission.

 

Also, I do not have access to the php.ini file as this is cluster hosting that I am using. I do have a server that I could test it out on.

Instead of

 

foreach ($servers as $server) {
file_get_contents_proxy($server['szURL'], $server['szProxy'], $server['iProxyPort']);
}

 

Use this

 

for($i=0;$i<count($servers);$i++) {
file_get_contents_proxy($server['szURL'], $server['szProxy'], $server['iProxyPort']);
}

Unfortunately, I am found replying with the same answer, again.

 

Please try fiddling around with the code on your own server, and let me know if you can manage to get the script to work. I will PM you the full script (including the password).

I have made some changes.

 

<?php

function file_get_contents_proxy($szURL, $szProxy, $iProxyPort)
{
$pCurl = curl_init($szURL);
curl_setopt($pCurl, CURLOPT_PROXY, $szProxy);
curl_setopt($pCurl, CURLOPT_PROXYPORT, $iProxyPort);

curl_setopt($pCurl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($pCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($pCurl, CURLOPT_SSL_VERIFYPEER, false);

return curl_exec($pCurl);
}

$password = "******";

$title = "IP Secured";

$url = "http://www.ipsecured.info";
$description = "IP%20Secured";
$note = "IP%20Secured%20--%20you%20no%20longer%20need%20to%20worry%20about%20filters.";
$tags = "ip%20secured,%20proxy";

$servers =array('szURL' => 'https://clooscript01:[email protected]/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '192.17.239.250',
'iProxyPort' => '3127');

for($i=0;$i<count($servers)-1;$i++) {
file_get_contents_proxy($server['szURL'], $server['szProxy'], $server['iProxyPort']);
}

echo "<a href='$url' alt='$title'>$title has successfully been submitted to <a href='http://del.icio.us/clooscript01'>clooscript01.";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.