pierredavidbelanger / chatter-bot-api

A Mono/.NET, JAVA, Python and PHP chatter bot API that supports Cleverbot, JabberWacky and Pandorabots.
182 stars 72 forks source link

Php example not working #6

Closed technocode closed 9 years ago

technocode commented 9 years ago

Hi.. i tested on my localhost.. chatterbotapitest.php.. but its not working... no reply form the bot..

Then, i modified the function to see the response form fopen...

$context = stream_context_create($contextParams); $fp = fopen($url, 'rb', false, $context); $response = stream_get_contents($fp); echo $response;

i got the following response: "DENIED +3000_cbfull"

pierredavidbelanger commented 9 years ago

Hi! Thank you for your feedback!

I have just tried to run the php test with the latest GIT:

$ php chatterbotapitest.php

And it works.

Does www.cleverbot.com at least works in your browser ?

Are you able to ping or traceroute to www.cleverbot.com ?

technocode commented 9 years ago

Thanks for the reply..

Finally i found the solution...

I changed the code from http_build_query($params); to http_build_query($params, '', '&');

And its work perfectly. The problem caused by the & might not be handled properly.

pierredavidbelanger commented 9 years ago

hum, you should not have to do this, as those are the default values:

http_build_query($params, '', '&');

What version of php to you use ?

Here, I use:

$ php --version
PHP 5.5.14 (cli) (built: Sep  9 2014 19:09:25) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
technocode commented 9 years ago

I'm using php 5.3.

I fixed my problem by referring this note on php.net

http://php.net/manual/en/function.http-build-query.php#102324

pierredavidbelanger commented 9 years ago

Oh, ok, you are right, "&" is not the default in php 5.3. Good to know! Also, good to know you fixed your bug. Thank you!

technocode commented 9 years ago

Welcome.

This API really great.

Thank you.