在 sharekit 中使用 t.co - iphone 应用程序 [英] Using t.co in sharekit - iphone application

查看:29
本文介绍了在 sharekit 中使用 t.co - iphone 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 sharekit,但我不想使用 bityl 服务来缩短 URL 我想使用 twitter 提供的内置 t.co.

我该怎么做?

谢谢.

解决方案

很遗憾,T.co 不能作为 API 提供给开发人员.这是 Twitter 用来自动缩短长链接的内部缩短程序.

查看 Raffi 的这篇博文,推特开发人员,以了解更多信息.

您将无法控制链接的缩短方式.但是所有超过 20 个字符的 URL 都会自动缩短,您可以通过在发送给 Twitter 的 POST 中包含 wrap_links=true控制缩短的内容新消息.

如果您在响应中启用 entities,您将看到您的以下属性链接.

"urls": [{"url": "http://t.co/0JG5Mcq","display_url": "blog.twitter.com/2011/05/twitte...","expanded_url": "http://blog.twitter.com/2011/05/twitter-for-mac-update.html",指数":[84,103]}],

<小时>

进一步参考:

Twitter 的 t.co URL 包装器现在适用于所有 19 个字符及以上的 URL

t.co 链接包装器的后续步骤

<小时>

编辑--->

如何使用 ShareKit 实现此功能:

Twitter 没有像 bit.ly 那样发布 APIURL,但如果您查看 ShareKit 库,您将看到以下文件,

/ShareKit/master/Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.m

打开此文件并查找以下行:

http://api.bit.ly/v3/shorten?login=%@&apikey=%@&longUrl=%@&format=txt

块内

self.request = [[[SHKRequest alloc] initWithURL:[NSURL URLWithString:[NSMutableString stringWithFormat:@"http://api.bit.ly/v3/shorten?login=%@&apikey=%@&longUrl=%@&format=txt",SHKBitLy登录,SHKBitLyKey,SHKEncodeURL(item.URL)]]

这是 ShareKit 发送给 Twitter 共享者的短 URL 字符串.

我还没有机会对此进行测试,但我认为如果您将此文本字符串更改为长 URL 文本字符串,则 ShareKit 会发送该字符串.

尽管框架中的其他地方可能有依赖 Bit.Ly 服务的区域,因此请注意这一点.但值得一试.

尽管 Twitter 不提供 T.co API,但截至 8 月 15 日它已开始将所有链接翻译为 t.co.因此,如果您通过上述步骤使用长网址,那么您应该会在响应中看到 T.co.

I am using sharekit but I don't want to use the bityl service for shortening the URL I want to use the built-in t.co provided by twitter.

How can I do that?

Thanks.

解决方案

Unfortunately, T.co is not available as an API to developers. It's an internal shortner used by Twitter to automatically shorten long links.

Check out this post by Raffi, Twitter developer, to learn more about it.

You won't be able to control how the links get shortened. But all URL's over 20 characters are automatically shortened and you can control what get's shortened by including wrap_links=true on the POST you send to Twitter for new messages.

If you enable entities in the response you'll see the following attributes for your links.

"urls": [
        {
          "url": "http://t.co/0JG5Mcq",
          "display_url": "blog.twitter.com/2011/05/twitte…",
          "expanded_url": "http://blog.twitter.com/2011/05/twitter-for-mac-update.html",
          "indices": [
            84,
            103
          ]
        }
      ],


For further reference :

Twitter's t.co URL wrapper is now on for all URLs 19 characters and greater

Next steps with the t.co link wrapper


Edit --->

How to get this working with ShareKit:

Twitter does not release an API like bit.ly does for URL's but if you look through the ShareKit library you will see the following file,

/ShareKit/master/Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.m

open this file and look for the following line:

http://api.bit.ly/v3/shorten?login=%@&apikey=%@&longUrl=%@&format=txt

inside the block

self.request = [[[SHKRequest alloc] initWithURL:[NSURL URLWithString:[NSMutableString stringWithFormat:@"http://api.bit.ly/v3/shorten?login=%@&apikey=%@&longUrl=%@&format=txt",
                                                                          SHKBitLyLogin,
                                                                          SHKBitLyKey,                                                                        
                                                                          SHKEncodeURL(item.URL)
                                                                          ]]

This is the short URL string ShareKit sends to the Twitter sharer.

I haven't had a chance to test this out, but I think if you change this text string to a long URL text string then ShareKit will instead send that one.

Although there may be areas elsewhere in the framework that rely on the Bit.Ly service so watch out for that. But it's worth testing out.

Even though Twitter does not offer a T.co API, as of Aug 15 it has started translating all links to t.co. So, if you use a long URL with the steps mentioned above then you should be seeing T.co in the response.

这篇关于在 sharekit 中使用 t.co - iphone 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆