Join Free
+ Reply to Thread
Results 1 to 7 of 7

Thread: Proper encoding

  1. #1

    Proper encoding

    I decided to put this in a new post since it likely got buried in the one it was in which was about a specific issue. This is more general:

    How is an affiliate deep feed link supposed to be encoded for Prosperent? Note that this is not sent via a hyperlink, but via the header command.

    like this (double encode)? :

    $url = "https://www.scorebig.com/most-popular/stl?Category=" . urlencode("pqlgod") . "&WhenStartDate=" . urlencode("05/18/15") . "&WhenEndDate=" . urlencode("05/26/15");
    $tourl = "http://prosperent.com/api/linkaffiliator/redirect?apiKey=myapikey&url=" . urlencode($url);
    header('Location: ' . $tourl );


    or this (single encode)? :

    $url = "https://www.scorebig.com/most-popular/stl?Category=pqlgod&WhenStartDate=05/18/15&WhenEndDate=05/26/15";
    $tourl = "http://prosperent.com/api/linkaffiliator/redirect?apiKey=myapikey&url=" . urlencode($url);
    header('Location: ' . $tourl );

    Both of these work for this example, but I would think Prosperent prefers one over the other.

  2. #2
    As I explained in the previous thread. You can't encode an encoded piece. It only goes through once. There is no such thing as a double encode. a + would always become a %2B and you can't encode a %2B again to somehow make it come out as a %2B on the merchant's side.

    If you send it via the header, a link or even smoke signals, the other end (Prosperent) decodes it once because it's the parameter you sent that they record and then forward to the merchant, once it's decoded, even the url parameters within the url you sent through as a parameter is decoded too. So the merchant gets a + and not a %2B.

    This problem isn't something you can solve on your end. Prosperent needs to change their decode to not decode url parameters WITHIN the url parameter you send that the merchant needs.

    The web standard stays the web standard, regardless of how you redirect or send that through. The middleman, Prosperent, is decoding url parameters within the url parameter that you send through.
    Last edited by AcidRaZor; 05-21-2015 at 04:27 AM.

  3. #3
    Actually, you can double encode (and triple and quadruple, at which point you're basically encoding the percent sign).
    It's not our job to selectively not decode URL parameters. How do we know?

    If the merchant's deep URL already has encoded parameters, then you'd encode them along with the rest of the URL. %2B would become %252b.

    It would get decoded once by prosperent on the redirect, and then decoded again by the merchant when their server receives the request.

    With the above example, they may both work, but the second one is not actually a valid URL with unencoded slashes in the query string. Most servers handle most improperly encoded URLs fine. The first example produces valid URLs, as long as that's the format the merchant is expecting.

    In any case, the correct way to do the encoding is to take a full merchant URL that works if you go directly to it in your browser, which may or may not have encoding in it, and encode the entire thing before putting it on the end of the linkaffiliator. Don't selectively encode stuff.

  4. #4
    I'll write up a few examples when I get the time

  5. #5
    Scott wrote:

    <<In any case, the correct way to do the encoding is to take a full merchant URL that works if you go directly to it in your browser, which may or may not have encoding in it, and encode the entire thing before putting it on the end of the linkaffiliator. Don't selectively encode stuff. >>

    That's my second example(I thought). The Scorebig url in the 2nd example when I put it in the browser goes to the right page.

    But just before this you wrote:

    <<With the above example, they may both work, but the second one is not actually a valid URL with unencoded slashes in the query string. Most servers handle most improperly encoded URLs fine. The first example produces valid URLs, as long as that's the format the merchant is expecting.>

    Isn't the query string the part after the question mark? Where are the unencoded slashes? If neither of my examples is valid, please modify my example to show me what it is you need to receive. I just want to know what works when the deep link is 'normal' -- the merchant didn't encode anything in the url to..
    Last edited by tedm; 05-21-2015 at 06:23 PM.

  6. #6
    Sure, technically, this is not a W3 valid URL:

    Code:
    https://www.scorebig.com/most-popular/stl?Category=pqlgod&WhenStartDate=05/18/15&WhenEndDate=05/26/15
    ...because it has slashes in the query string values. But again, most web servers handle it fine, because they split off the query string first at the ?.

    But if that's what the merchant uses, then it's ok.

    It's what you did to it in the second example that's correct, which is to simply encode the entire working URL and put it in the linkaffiliator.

  7. #7
    Thanks Scott, I wasn't picking up on which slashes you were referring to that were unencoded since I was encoding it. Got it now. Ted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
coupons | coupons and deals