Jacksonkr
Jacksonkr

Reputation: 32247

php fread a url with htaccess password?

$handle = fopen(site_url() . "/?post_type=tab_content&p=$content_id&_parent_id=$parent_id&_page_id=$page_id", "r");
$contents = fread($handle, filesize($filename));
fclose($handle);

gives me:

Warning: fopen(http://dev.yoursite.com/website/?post_type=tab_content&p=424&_parent_id=92&_page_id=110): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /var/www/domains/dev/website/wp-content/themes/insource/index.php on line 82 Warning: fread() expects parameter 1 to be resource, boolean given in /var/www/domains/dev/website/wp-content/themes/insource/index.php on line 83 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/domains/dev/website/wp-content/themes/insource/index.php on line 84

Is this something I can bypass with php? Many thanks-

Upvotes: 0

Views: 609

Answers (2)

Patrick Moore
Patrick Moore

Reputation: 13354

You should be able to supply the username and password as part of the URL string, much like with FTP connections:

http://username:[email protected]/path/

Upvotes: 2

Matteo Tassinari
Matteo Tassinari

Reputation: 18584

You could try to put inline username and password like this:

http://username:[email protected]/website/?post_type=tab_content&p=424&_parent_id=92&_page_id=110

which should work for the basic http authentication

Upvotes: 2

Related Questions