2017-03-29 22 views
0

FacebookのメッセンジャーAPIのウェブサイトのHTML出力を読み込もうとしていますが、コードはサーバで動作していますが、facebook api(メッセンジャー)で試してみるとエラーになります。私が得るもの:facebook apiのhtmlページを読むことができません

Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. 

私はfile_get_contents、fopen、readfile、curlを試してみたのと同じエラーが発生しました。
私はhttps://google.comに、カールを使用するときに安全な接続(https)をするウェブサイトを変更しようとした、とエラーメッセージがに変更:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> 
    <TITLE>302 Moved</TITLE></HEAD><BODY> 
    <H1>302 Moved</H1> 
    The document has moved 
    <A HREF="https://www.google.ca/?gfe_rd=cr&amp;ei=SaHbWPOrQXp_JvNB">here</A>. 
    </BODY></HTML> 

そしてstackoverflowのは示しています

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
    <html><head> 
    <title>403 Forbidden</title> 
    </head><body> 
    <h1>Forbidden</h1> 
    <p>You don't have permission to access/
    on this server.<br /> 
    </p> 
    <p>Additionally, a 403 Forbidden 
    error was encountered while trying to use an ErrorDocument to handle the request.</p> 
    </body></html> 

何私はする必要がありますか?

答えて

0

Googleはiframe内に使用され、Googleのサーバブロック、それは、あなたのコードは、他のサイトでうまく動作するでしょうがカールすることができない、唯一の方法は、OWMページを作成し、google search api.

のコード例を使用することです

外部アプリケーションにGoogle認証が必要な場合や、このライブラリでGoogle APIがまだ利用できない場合は、HTTPリクエストを直接行うことができます。

authorizeメソッドは、許可されたGuzz Clientを返します。したがって、クライアントを使用して行われた要求には、対応する権限が含まれます。

// create the Google client 
$client = new Google_Client(); 

/** 
* Set your method for authentication. Depending on the API, This could be 
* directly with an access token, API key, or (recommended) using 
* Application Default Credentials. 
*/ 
$client->useApplicationDefaultCredentials(); 
$client->addScope(Google_Service_Plus::PLUS_ME); 

// returns a Guzzle HTTP Client 
$httpClient = $client->authorize(); 

// make an HTTP request 
$response = $httpClient->get('https://www.googleapis.com/plus/v1/people/me'); 
関連する問題