-1

I'm working with the Trello API. I want to attach an image to a newly created card. I have no problem POSTing the new card and getting the card id to then PUT the attachment.

My project is made in Laravel 5.4 and I'm using Guzzle to make the HTTP requests.

The image I want to attach is from the Google static maps API and I'm using an encoded polyline (which I generate using this script) to draw a figure over some area.

This is how the card should look like:

enter image description here

But it ends up looking like this:

enter image description here

If I go to Trello and attach the image (as an URL) manually everything works perfectly but when I do it through a HTTP request it looks like the second image above.

After doing some research I think the problem resides in the polyline string because it usually contains some characters that HTTP does not support. I've tried using PHP's urlencode() without any result.

I send the image URL as an URL encoded param since that is the only way the Trello API accepts it (even though the official Trello API docs say otherwise).

Do you guys have any other ideas | work-arounds | experience with this issue?

freddieRV
  • 101
  • 3
  • 7

1 Answers1

1

I think you can try to use Google URL Shortener or similar service to convert the complicated URL with encoded polyline to something really simple.

For example, I have the following static maps URL with polyline

https://maps.googleapis.com/maps/api/staticmap?size=512x512&scale=2&maptype=terrain&style=feature:all&path=weight:3%7Ccolor:0xff0000ff%7Cgeodesic:true%7Cenc:}sp}Gmrkl@m@wIiAaB_BaA}IcCmLoFqG_DuFkAyN[mEiBqN}MqFsLqUoxAyG{@qGqJwDkBeJMod@lScMzFcFvAwHn@wH[oGwAwI{EwFqGaHwKcS{e@mKkd@iGsi@wKem@iKg[aPg[_N_RiE{EoUaR{f@}X}d@sWo[mN}]_KqYcDePyCcQaGeUuM{PoO_SsWcLeTiSsi@{Ka[yRgb@sN{S}RaS_XkRiX{OiO{GgMiEoc@aDwq@{Eig@qHyhAeQ{n@Nqj@uOqp@qTcZmNyZkUcRkSsIiL{Qq[qHuPuLk]wIe]mLqd@sLm\kf@yAiRm^oXwe@uAazA}JgR{Qeb@yHsX}Gg\uDyViEwn@wHup@w@sCyT~AaKgo@qJmg@kGaT}Qud@cZch@y{@{gB_OeTaPkQkf@ae@kQcQ}MwPoQu[{GgPkJiZiEoRaIgh@_Gm[oQyj@kPk\iPkTi[cYuOyIqQsGcYuFm]gCug@g@cU{G}IaGeHcH}IsMyFaMsKi]eLw@qKab@kIwe@eDkLyKwRiGsFoOuGcGkAuQm@uH_@{W}DmOkFcJ}E_MkJ{WgTkLgL}I_KwJgGcHoBeGMaIjBuDhA_GRab@aEoKuCqFaEoIsQaG}NkDuL_@qR~BmNdR{b@zEaW~Cee@vEsv@vA}JfEeNpG_Q|A_HfAwOq@qQ{DeRgSou@eb@i|AyJc^aKcOeHyEm_@aNeOsFkDiCmEaGiIiV}e@__B}Kkc@{Q{fAg\wpBkLqrAeWuiDyUuwCqGak@aA_SFeNjCwWhI_WMaRjFgLbVueAdHa[fP}w@fAqT_BoVoHi}@{Hq{@yF}QyFaImH_FaQqGmQcJqH}IuWag@yFkQ{FyZcVcmAeJ_W{LcRqOaNgK{KeI{PeFoW}@eTp@qp@e@oRqHkr@gx@{|IwA_St@iSbAgNnGsXhRks@pNwk@bQsp@tVu|@zF}PhN}\rDoH~BaCvDqEn]el@fP_VrDiFbDaCdXoMbIgErCcDpCaFdCqIpFil@vFsq@ViQ}@qS{Bop@uCkaA{@o[\yVN{t@~W{zAdVowAZeNvA_MbEmTxHeZb@}IpCwQbIe@jMgp@tC_PvFkT~CgMdAaGeAGq@xDkAhEaBdHsBvIcESG|OsAlKaDlF{ErBgFg@}CoCaDcI{EcQ}F{FcHaDiNiGwGoDwGgEgOkEca@mQmVaLyFgEcIiOaG_QiDuLsBuCuJkIgWsT_m@uj@iPgNqSaEoKc@cBRgFpB_DdCqMjHyJxCsJv@aW_AcNsGuF}J&key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU`

Now I apply the shortener service and get this URL: goo.gl/iytwvS

So, I can use the latter as src of the image as shown in the following example

http://jsbin.com/quridub/edit?html,output

I hope this helps!

xomena
  • 31,125
  • 6
  • 88
  • 117