matthiasnoback / microsoft-translator

PHP library for making calls to the Microsoft Translator V3 API
MIT License
39 stars 26 forks source link

file_get_contents fails #11

Closed tsusanka closed 10 years ago

tsusanka commented 10 years ago

Hi, thx for great library. I am not sure if this is an issue or just my problem.

I've installed the library and tried your example in the readme. However I am getting a MatthiasNoback\Exception\RequestFailedException with message:

Request failed: file_get_contents(https://datamarket.accesscontrol.windows.net/v2/OAuth2-13): failed to open stream: operation failed

I've dumped the arguments in Browser and the url is https://datamarket.accesscontrol.windows.net/v2/OAuth2-13, headers are empty and content is equal to client_id=id&client_secret=secret&scope=http%3A%2F%2Fapi.microsofttranslator.com&grant_type=client_credentials.

I have a kind of fresh php install, is there some special module/extension I need?

php 5.4.24 ubuntu 12.04 LTS

Thx in advance for any help.

matthiasnoback commented 10 years ago

Thanks for reporting. In my situation it helped to use a different browser client from Buzz: the Curl client. You could try that first before we dive in deeper.

tsusanka commented 10 years ago

Yes indeed! It helped, curl is working as a charm. Thx

shailendrac commented 9 years ago

I am also facing the same issue. Could you please help what changes you made for using curl..

Got it Worked for me Thanks for great library

matthiasnoback commented 9 years ago

For completeness' sake, instead of:

use Buzz\Browser;

$browser = new Browser();

provide an explicit client, other than the default FileGetContents client:

use Buzz\Client\Curl;

$client = new Curl();
$browser = new Browser($client);
shailendrac commented 9 years ago

Thanks I used: $browser->setClient($curl); instead, works for me the same way

matthiasnoback commented 9 years ago

You're welcome and that's right :)