Alright, so I'm working on a money tree grabber to refresh myself on Java. Whenever the program tries to grab something from the tree, the page returned is that "You have been directed here from the wrong place" error message, leading me to think the referer isn't being set correctly, since I can manually grab things without any problems.
I checked all the logical things first, just as the program correctly parsing the individual URLs, etc., but it's all fine.
Code in the program to grab the item (whose URL is stored in donationurls at index j), and the relevant wrapper code:
wrapper.setReferer("/donations.phtml"); strHTML = wrapper.get("/takedonation_new.phtml?donation_id=" + donationurls[j]);
public String setReferer( String domain ) { referer = domain; return null; } public String get( String url ) { if( url.charAt( 0 ) == '/' ) url = domain + url; try { HttpURLConnection conn = (HttpURLConnection)( new URL( url.replaceAll( " ", "%20" ) ).openConnection() ); setRequestProperties( conn ); conn.setRequestMethod( "GET" ); referer = url; return read( conn ); } catch( IOException e1 ) { e1.printStackTrace(); return null; } } private void setRequestProperties( HttpURLConnection conn ) { ... if( referer != null && referer.length() != 0 ) conn.setRequestProperty( "Referer", referer ); ... }
I seriously have no idea what's wrong. I've been stuck at this stage for a day and nothing I do is working. Frustrating, to say the least.