简体   繁体   English

如何使用Pharo获取Twitter Feed?

[英]How do I get a Twitter feed using Pharo?

Since Twitter changed their website design, I cannot get a set of tweets from any account by using built-in Zinc classes. 由于Twitter改变了他们的网站设计,我无法通过使用内置的锌类从任何帐户获得一组推文。 It throws an error that says: ConnectionClosed: Connection closed while waiting for data 它抛出一个错误: ConnectionClosed: Connection closed while waiting for data

I am using Pharo 5 , and I don't know how to tweak the ZnClient settings in order to keep the connection open or something to the purpose of getting the data. 我正在使用Pharo 5 ,我不知道如何调整ZnClient设置以保持连接打开或达到获取数据的目的。

testTwitter
    | client |
    self ensureSocketStreamFactory.
    self isNativeSSLPluginPresent ifFalse: [ ^ self ]. 
    (client := ZnClient new) 
        get: 'https://www.twitter.com/pharoproject'.
    self assert: client isSuccess.
    self assert: (client contents includesSubstring: 'Twitter').
    client close

That's the test I have in place, it never passes, and throws the error mentioned above. 这是我的测试,它永远不会通过,并抛出上面提到的错误。 What's missing here? 这里缺少什么? I did a Ruby script using open-uri, openssl and Nokogiri and it fetched the tweets just fine. 我使用open-uri,openssl和Nokogiri编写了一个Ruby脚本,并且它可以很好地获取推文。 Perhaps it's a problem with the SSL connection itself? 也许这是SSL连接本身的问题?

The issue here is quite easy to answer, but you won't like it. 这里的问题很容易回答,但你不会喜欢它。 Your issue is connected to the fact that the Twitter has deprecated support for TLS 1.0, TLS 1.1 on July 15/2019 . 您的问题与Twitter于2009年7月15日弃用对TLS 1.0,TLS 1.1的支持这一事实有关 Your pharo is using the deprecated TLS to connect. 您的pharo正在使用已弃用的TLS进行连接。 That is the reason why you are getting the timeout. 这就是你获得超时的原因。

The solution? 解决方案?

You have to compile the new SSL/TLS support yourself which is not an easy task to do. 您必须自己编译新的SSL / TLS支持,这不是一件容易的事。 You have to compile in at least TLS 1.2 to be able to connect again. 您必须至少编译TLS 1.2以便能够再次连接。 There is lack of Pharo documentation how to compile support for new libraries. 缺乏Pharo文档如何编译对新库的支持。 My guess is that you are using TLS 1.0 (see a note below) - since Pharo 6.1 (so your Pharo 5.x will have same or older libraries) has libgit2.so compiled against libssl.so.1.0.0 (which has dependency libcurl-gnutls.so.4 ) - If you update the libraries you can see that those support >= TLS 1.2. 我的猜测是你正在使用TLS 1.0(参见下面的注释) - 因为Pharo 6.1(所以你的Pharo 5.x将有相同或更旧的库)有针对libssl.so.1.0.0编译的libgit2.so (具有依赖性) libcurl-gnutls.so.4 ) - 如果更新库,可以看到那些支持> = TLS 1.2。

Note: 注意:

This is connected to the issue which I have posted some time ago. 这与我前一段时间发布的问题有关。 Nobody upvoted it or answered so it got automatically deleted - you can vote to undelete it: https://stackoverflow.com/questions/51399321/getting-error-when-adding-ossubprocess-to-my-pharo-6-1-on-centos-7-4x (see the bottom of the post for the question). 没有人投票或回答所以它被自动删除 - 你可以投票取消删除它: https ://stackoverflow.com/questions/51399321/getting-error-when-adding-ossubprocess-to-my-pharo-6-1- on-centos-7-4x (请参阅帖子底部的问题)。 I don't have an answer for that as I have dedicated time to my Smalltalk/X project. 我没有答案,因为我有时间专注于Smalltalk / X项目。

Or just switch to a newer Pharo. 或者只是换一个新的Pharo。 Adding your method to ZnHTTPSTest in Pharo 8 just works (tested on Pharo 8 build 686 , Ubuntu 18.04.02 LTS with the stable vm in PharoLauncher ) Pharo 8 ZnHTTPSTest您的方法添加到ZnHTTPSTest中(在PharoLauncher中使用稳定的v​​m,在Pharo 8 build 686 ,Ubuntu 18.04.02 LTS上PharoLauncher

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM