datasift / datasift-php
此包已废弃,不再维护。未建议替代包。
关于此包最新版本(2.7.1)没有提供任何许可信息。
2.7.1
2016-08-22 09:42 UTC
Requires
- ext-curl: *
README
此项目不再积极维护。请自行承担风险!
DataSift PHP 客户端库
这是访问DataSift的官方PHP库。请参阅示例文件夹以获取一些简单示例用法。
入门指南
要开始,请选择我们的快速入门指南之一
简单示例
此示例查找包含单词"datasift"的所有内容,并将其内容简单地打印到屏幕上。
<?php // Load the library (If you're using this library standalone) require 'lib/datasift.php'; // Load the library via Composer //require '/path/to/vendor/autoload.php'; // An object of this type will receive events class EventHandler implements DataSift_IStreamConsumerEventHandler { public function onInteraction($consumer, $interaction, $hash) { echo $interaction['interaction']['content']."\n"; } // Ignore the other events for the purposes of this example. public function onConnect($consumer) { } public function onDeleted($consumer, $interaction, $hash) { } public function onStatus($consumer, $type, $info) { } public function onWarning($consumer, $message) { } public function onError($consumer, $message) { } public function onDisconnect($consumer) { } public function onStopped($consumer, $reason) { } } // Create the user $user = new DataSift_User('your username', 'your api_key'); // Create a definition looking for the word "datasift" $def = $user->createDefinition('interaction.content contains "datasift"'); // Get an HTTP stream consumer for that definition $consumer = $def->getConsumer(DataSift_StreamConsumer::TYPE_HTTP, new EventHandler()); // Consume it - this will not return unless the stream gets disconnected $consumer->consume(); ?>
有关每个交互中数据的详细信息,请参阅DataSift文档。在我们的开发者网站上,您可以查看示例交互:[http://dev.datasift.com/docs/targets/interaction/mapping](http://dev.datasift.com/docs/targets/interaction/mapping)
要求
- PHP 5,启用cURL扩展,并使用openssl进行SSL支持
- JSON(PHP 5.2+中包含,否则请使用http://pecl.php.net/package/json)
默认情况下,库将使用SSL连接。虽然我们建议使用SSL,但如果需要,您可以通过在创建用户时将第三个参数传递为false,或在用户对象上调用$user->enableSSL(false)来禁用它。
测试
要测试库本身,请运行测试
composer test
贡献
有关详细信息,请参阅CONTRIBUTING
致谢
许可
此存储库中包含的所有代码版权所有(C)2011-2015 MediaSift Ltd。
此代码根据MIT许可证(MIT)发布。有关更多信息,请参阅许可文件。