Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php example not working #6

Closed
technocode opened this issue Nov 27, 2014 · 6 comments
Closed

Php example not working #6

technocode opened this issue Nov 27, 2014 · 6 comments

Comments

@technocode
Copy link

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

Welcome.

This API really great.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants