dsf4354353452 2016-08-21 18:35
浏览 72

Bitly API不使用用户的默认域名。 我怎么做到的?

Background: According to Bitly's API documentation, when a link is shortened via their API, it should be shortened using the domain that the authenticated user has set as their default domain if no domain is specified in the API request.

Parameters

longUrl - a long URL to be shortened (example: http://betaworks.com/).

domain - (optional) the short domain to use; either bit.ly, j.mp, or bitly.com or a custom short domain. The default for this parameter is the short domain selected by each user in their bitly account settings. Passing a specific domain via this parameter will override the default settings.

format - json, xml, txt. Default: json.

Quote taken from Bitly's API documention found here: https://dev.bitly.com/links.html#v3_shorten

Problem: In my plugin, however, it ALWAYS returned the link shortened in the bit.ly format and NEVER returns a link shortened using the a custom short domain. This is the case both in my testing and for several other users who use this scrip.

Context: You can see my function starting on line 203 of this GitHub file here: https://github.com/warfare-plugins/social-warfare/blob/master/functions/bitly.php

You can see that actual API request being built down on line 230.

I tried manually declaring the domain parameter, and it still failed to produce the desired results.

Question: So how do I get it to use the user's default domain name instead of always using the bit.ly domain name?

  • 写回答

1条回答 默认 最新

  • dongzhuo7291 2016-08-22 17:47
    关注

    Bitly Engineer here ...

    First, you can get direct Bitly API support at api@bitly.com.

    The current user is determined by the access token that you pass to the API call. We then determine the default domain for that user. So likely, the default domain for whatever user is tied to the access token you are passing is bit.ly.

    So how do I get it to use the user's default domain name instead of always using the bit.ly domain name?

    Just call the API w/ the access_token for the user. You would generally get this via oauth flow for a multi-user application. If there is a specific example of this not working feel free to contact us at the support email and we can debug further.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度