![]() |
Proxifying file_get_contents [URGENT!]
PHP Code:
|
I don't believe there's any way to add proxy support to the native
file_get_contents(), but I've wrote you a function below, file_get_contents_proxy() that adds proxy support via the cURL library which will need to be enabled.Note: Really tired so it may not even work :( ! Someone else will be able to help you from this if not. PHP Code:
|
PHP Code:
|
Not sure what you're trying to do but how about something like this:
PHP Code:
|
Just to clarify, there's no need to use CURL in order to pass the request through a proxy but it's likely the fasted method.
I've coded up a quick and dirty class which might help. The file_get_contents_proxy method shows you how to use a proxy in conjunction with PHP's file_get_contents function (key point: it uses a context).Also, it seems that a number of your proxies weren't allowing SSL communication so that's why I've used the same proxy in my sample class. But you can use any that you find to work. Here's the class, sorry it's quite long and messy but *touch wood* it works for me. PHP Code:
PHP Code:
|
@Wildhoney - A blank page is loaded, but none of my del.icio.us pages update.
@Salathe - I receive different error messages, depending on the version of PHP that is running. PHP 4: PHP Code:
PHP Code:
|
Change the proxies (I did notice lots of yours wouldn't accept the connection, or would time out) and/or the timeout values.
|
Okay, I have just tried another 20 from my proxy list, and it still hasn't worked.
I have also tried 10 from http://www.publicproxyservers.com/page1.html and they are producing the same results. Thank you. :) |
Can you query the del.icio.us API without using a proxy server?
|
The issue has been resolved. Thank you for all of your help. :)
|
Old Thread New PHP Programmer
I can see that this thread is a few years old. However, it turned up as one of the only results for connecting a proxy to file_get_contents. I've been learning php for the last two weeks and I've been trying a few experiments. For simplicities sake here's a little program I put together that uses Yahoo, cycles through a set amount of Yahoo pages and searches each page for a word.
PHP Code:
I have a subscription to a page that I log into that gives me access to a simple page of proxies updated with new ones every second. The conveniently comes out in the following format: proxy1:portA proxy2:portB proxy3:portC I'll be reviewing the earlier responses in this thread to see if I can figure out how to do this. Essentially I want the script to: 1> Auto log into my proxy page 2> Grab five random proxies (or top proxies) 3> Use them to make requests as per the script above 4> Loop back to "2" and get more proxies I would think this would eliminate the block by Yahoo has the results are coming from multiple IPs. Am I on the right path? |
Hi soma56, welcome to TalkPHP.
Yes, it looks like you're thinking along the right lines if you do want to avoid them blocking of those pages. However, there might be other routes that you can use. Note that Yahoo! has a bunch of special services (e.g. BOSS) designed for being accessed by scripts, providing programmatic access to things like the search results that you're wanting; this would likely avoid the need for proxies entirely. |
:)
Thank you. I'm taking a crash course on cURL right now. I've have a look a BOSS and follow up in a new thread.
|
| All times are GMT. The time now is 02:17 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0