I have used this code and put it in localhost and it is loading , don’t know what is happening
I'm afraid it is not clear what your issue is. The code you have is straight from the PHP client library readme, this is supposed to be a basic example of how to consume a stream where the interaction.content contains the word "datasift". If you have this running and there are no live interactions that contain the word "datasift" you will not receive any data. The PHP client library's github page can be found here.
If you are just starting to use the datasift API I would recommend visiting our documentation site.
First of all when i run this code its loading and loading and loading … no data is returning
Secondly you stated " If you have this running and there are no live interactions that contain the word “Datasift” you will not receive any data." what do you mean by live interaction , interaction between whom . My requirement is straight forward , I have a site in which i have to fetch data which contain the word stock. How do I do this as there are lots of instructions in the site but not described how to use them also this example code is not working so that i could check anything , at-least i expect an “error” so that I could know what I have to do .
Expecting a quick response.
The example code is not throwing an error because it is working as expected - the CSDL is valid and is monitoring for any interactions that mention the word "DataSift". However, it appears you have not turned on any data sources on your account. You can do so here. Once you have some sources enabled, you can modify the CSDL to something with more volume (ie. interaction.content contains_any "stock") and you should be able to see interactions come in.
Please let us know if you have any further questions.
Hi, I am a PHP developer.
public function onInteraction($consumer, $interaction, $hash)
If you are expecting something to echo in the above event handler, since the code is loading and loading and loading for ever, you will not be able to see the output in browser. The output will be displayed only after you stop the execution.
Alternatively, you can try to write the content to a file (in append mode) and watch that file using the linux command tail -f filename. You can see the content appending to the file.