Code Monkey home page Code Monkey logo

Comments (9)

elrido avatar elrido commented on June 12, 2024 1

This looks pretty close to what we merged recently with #997 - Could you compare your implementation with that one and let us know if it would still add any additional features over that implementation or other benefits your implementation might have, that we should improve in the other?

from privatebin.

elrido avatar elrido commented on June 12, 2024 1

Ok, so several points seem to be worth improving. I personally would not want to have 2 (or 3, if you count the generic urlshortener implementation) to maintain in the project, especially since I do myself not use this, admittedly popular, feature. I would therefore prefer to a merge request that adds features or rewrites the logic of to the YourlsProxy class.

We deliberately avoid using the curl library, since the request is a very simple one and none of the crafty, advanced curl features should be required in this case - this lets us avoid requiring this extra dependency, keeping the container image sizes small:

$data = file_get_contents(
$yourls_api_url, false, stream_context_create(
array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query(
array(
'signature' => $conf->getKey('signature', 'yourls'),
'format' => 'json',
'action' => 'shorturl',
'url' => $link,
)
),
),
)
)
);

For the JSON parsing we use a small OOP wrapper, that throws when detecting an error, so we don't forget to check for them:

try {
$data = Json::decode($data);
} catch (Exception $e) {
$this->_error = 'Error calling YOURLS. Probably a configuration issue, like wrong or missing "apiurl" or "signature".';
error_log('Error calling YOURLS: ' . $e->getMessage());
return;
}

from privatebin.

elrido avatar elrido commented on June 12, 2024

@ajsap Did you have time to compare your implementation with the existing one? What features do we lack?

from privatebin.

ajsap avatar ajsap commented on June 12, 2024

from privatebin.

ajsap avatar ajsap commented on June 12, 2024

from privatebin.

elrido avatar elrido commented on June 12, 2024

Fair enough, take care.

from privatebin.

rugk avatar rugk commented on June 12, 2024

Also, please don't use ChatGPT to reply to issues or at least tell it not to write it's default longish stuff. And if you did not use it I am sorry, but otherwise please just be transparent about it.

from privatebin.

ajsap avatar ajsap commented on June 12, 2024

from privatebin.

rugk avatar rugk commented on June 12, 2024

Oh I am sorry, I overread it. Especially as email replies (especially with that long signature/addendum) get rendered as very long texts on GitHub. I don't know how accessible GitHub's website is, but if it is possible for you, you could reply here too or so.
And no did not use any software for that, was a pure guessing based on thee writing style. Again I am sorry.

from privatebin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.