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:$password@api.del.icio.us/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
Share on other sites

  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

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

 

<?php

  $servers = array(
    array(
      'szURL' => 'https://clooscript01:$password@api.del.icio.us/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']);
  }

?>

Link to comment
Share on other sites

<?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:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
      'szProxy' => '221.233.134.87',
      'iProxyPort' = '8080'
      ),
    array(
      'szURL' => 'https://clooscript02:$password@api.del.icio.us/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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '192.17.239.250',
'iProxyPort' => '3127'
),
array(
'szURL' => 'https://clooscript02:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '128.8.126.112',
'iProxyPort' => '3124'
),
array(
'szURL' => 'https://clooscript03:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '129.240.67.18',
'iProxyPort' => '3128'
),
array(
'szURL' => 'https://clooscript04:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '212.241.168.184',
'iProxyPort' => '80'
),
array(
'szURL' => 'https://clooscript05:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '156.17.10.52',
'iProxyPort' => '3124'
),
array(
'szURL' => 'https://clooscript06:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '61.16.154.132',
'iProxyPort' => '80'
),
array(
'szURL' => 'https://clooscript07:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '156.17.10.51',
'iProxyPort' => '3124'
),
array(
'szURL' => 'https://clooscript08:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '194.103.159.85',
'iProxyPort' => '80'
),
array(
'szURL' => 'https://clooscript09:$password@api.del.icio.us/v1/posts/add?url=$url&description=$description&extended=$note&tags=$tags&shared=yes',
'szProxy' => '213.114.118.44',
'iProxyPort' => '8080'
),
array(
'szURL' => 'https://clooscript10:$password@api.del.icio.us/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 />";

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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:$password@api.del.icio.us/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.";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.