2014-07-12 31 views
1

配置我有啓用計費,並有10 $的平衡在我的項目, 我已經創建了一個瀏覽器應用的關鍵,與正確引用生成密鑰,我下面訪問不使用PHP谷歌翻譯V2

$api_key = 'My Key is Here'; 


$response = file_get_contents('https://www.googleapis.com/language/translate/v2?key='.$api_key.'&q=hello%20world&source=en&target=de'); 

//decode json to array 
$json = json_decode($response); 

//show the json array in a readable format 
echo '<pre>'; 

//show array 
print_r($json); 

我收到以下錯誤

stdClass的對象 代碼給出( [錯誤] => stdClass的對象 ( [錯誤] =>數組 ( [0] => stdClass的對象 ( [域] => usageLimits [原因] => accessNotConfigured [消息] =>接入未配置。請使用Google Developers Console爲您的項目激活API。 )

  ) 

     [code] => 403 
     [message] => Access Not Configured. Please use Google Developers Console to activate the API for your project. 
    ) 

請你會幫我搞清楚,我已經錯過了或做了錯事,我得到上述錯誤。

很多謝謝

回答

0

確保您已經在開發者控制檯中啓用了翻譯API。 enter image description here