2012-07-31 73 views
0

可能重複:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in selectPHP fread與htaccess密碼的網址?

$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); 

給我:

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 

這是不是我可以用PHP繞過?許多thanks-

+1

退房[這個問題](http://stackoverflow.com/q uestions/2140419/how-do-i-make-a-request-using-http-basic-authentication-with-php-curl) – 2012-07-31 15:33:11

+0

@Fabio尼斯鏈接。這絕對是很好的信息。謝謝! – Jacksonkr 2012-07-31 21:35:27

回答

2

你可以嘗試把在線用戶名和密碼這樣的:

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

應爲基本的HTTP認證工作

2

你應該能夠爲部分提供的用戶名和密碼URL字符串,很像用FTP連接:

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