5/16/2018

The Iran Contract is Dead Already

You may notice that the headline say "contract", not "deal". I hate the word "deal", it sounds a bit like a shady car dealership to me, and "contract" makes it more clear that there is a legally binding (in theory) document that had been written after careful negotiations, and there was no rip-off as in so many "deals" there is.

Anyway, after the US illegally backing out and illegally and very rudely telling the EU that they can choose between wither dealing with Iran of the US, it seems the EU, and in particular Germany have not grasped the situation yet.

They tell Iran in all seriousness that the EU will honor the contract and ask Iran to do the same. Are they blind, deaf, brain-dead, or all of the above?

The trade between the EU and Iran is but a small fraction (about 3%) of the volume they trade with the US. Do they seriously think that companies will happily give up 500 billion in trade in favor of the 15 billion they trade with Iran?

Companies are neither political, nor are they empathic, they are run for the sole purpose of makin profits, and they will simply look for the bigger chunk.

I am not sure what the EU are playing at here. They can of course politically honor the contract, but their industry will nevertheless cease operations with Iran - bottom-line there it will make no difference whether the EU breaks the contract as well, and imposes new sanctions.

Of course, by politically staying in the contract, they can (and do) urge Iran, to also honor its commitments.

Albeit, as mentioned above, for Iran it does not really matter what the EU does - they will just loose their imports and exports, including those from/to the EU.

Can you honestly expect Iran to stay with the contract, when all the benefits are gone anyway?

Israel, Saudi Arabia, and last bit not least the US are tightening the military screws as well. What other realistic choice does Iran have that to build weapons to defend itself, when all benefits of not doing so have already been taken away?

Of course it is this very reaction the Trump administration is counting on. In this event they will join forces with Israel and Saudi Arabia and declare war on Iran, which is what they have been planning all along, such as Trump's "security advisor" John Bolton, who publicly said hat he wants to see a "regime change" in Iran in 2018.

Despite this very obvious plot, I am afraid that what I just outlined above is exactly what is going to happen. Iran is already caught in a "mouse trap" an cannot choose its actions freely any longer.

I don't care for governments and politics at all, least of all for the Iranian*, but this prospect really makes me sad for a beautiful country and its innocent and likeable inhabitants.


*: maybe one exception: the Israeli government

Netflix and IMDb

When looking for movies or series worth watching on, I used to spend hours with a growing sense of frustration.

Of course, the shows need to be a mix, one, to server different audiences, but most importantly, second, to stay within budget. However, I cannot help the feeling, that the largest part of the offerings are, well, crap. On the other hand, there is some really good stuff there, too.

Only, how do I find the good stuff more quickly? There used to be great Grasemonke/Tamptermonkey user scripts, that would show ratings from Rotten Tomatoes, IMDb and the like alongside the movies on Netflix. Unfortunately, all of them stopped working after some time, and I was left again looking for the needle in the haystack.

That is, until I recently found a user script that shows those IMDb ratings again. It is admittedly a little more work that just click-install (you have to get a free key and put it in the code yourself), but it works, and that's all that matters for me.

It does not show ratings for all items (no idea why), and I am a pick person, so I don't want to watch anything that got less that a 7.0 on IMDb, but even with these restrictions is took me only 30 minutes to fill my list with 10 titles I want to watch.

As you can see, my ratio of watching versus searching has improved considerably :-)

If you are looking for a similar treat, you check the user script out yourselves here.

5/09/2018

Verifying a Playstore in-app purchase with PHP

Of course you can verify an IAB purchase in your Android app, but that means you have to have your API key somewhere in the app. In the worst case, hackers can get your key, at the very least it is easy to tamper with your verification code through reverse-engineering of the app.

This is why Google recommend checking purchases on the server. Here is how to do this in PHP.

First of all, you have to get your key from the Play Console:



Save the key to a text file. The following code assumes the file is in the same directory as the PHP script and is named "Publishing-API-Key":

function verifyPurchaseSignature($data, $signature)
{
    $key = file_get_contents("Publishing-API-Key");
    $key = openssl_get_publickey($key);

    if(null === $key)
    {
        reportError("Cannot verify purchase: invalid API key!");
        exit();
    }

    $result = openssl_verify($data, base64_decode($signature), $key, OPENSSL_ALGO_SHA1);

    if(0 === $result)
    {
        return false;
    }
    else
    {
        return true;
    }
}

The data parameter contains the JSON data from the play store purchase (do not re-format or add newlines).
The signature parameter contains the signature from the play store purchase. which is a Base64 string.

If you host this code on a web server, make sure that the file containing your API key is not externally accessible!

5/07/2018

Debugging an Android App that uses In-App Purchasing

In order to get In-App Purchasing to work in the first place, make sure you meet the following requirements:
  • Manifest file must include com.android.vending.BILLING permission.
  • APK is
    • built in release mode
    • signed with the release certificate
    • uploaded to alpha/beta distribution channel in the Developer Console
    • published to testers
  • in-app products are published in the Developer Console and their status is set to active.
  • Test account is added in Developer Console. You cannot test the purchasing process with your developer account!
  • Test account is opted-in as a tester and it's linked to a valid payment method.
Now, to debug the application with in-app purchasing working, you need to change few things:

In the Manifest add the following as an attribute to the application node:
android:debuggable="true"
tools:ignore="HardcodedDebugMode"
In your Build.gradle file (for the app module) under android > buildTypes > release, add:
debuggable true
Compile your app. Because of the previous changes, it will be debuggable now, even if you build it in release mode. Ensure that this APK:
  • is built n release mode
  • has the same versionCode as the one uploaded to Developer Console.
  • is signed with the same certificate as the one uploaded to Developer Console.

Now you can debug the app from from Android Studio as if you had built a debug version, and in-app purchasing will work. Change the code, recompile, everything works fine as long as you stick to release mode.

To test in an Adroid Virtual Machine or emulator, you need to pick an image that includes Play Store. As of this writing, the only images that do so are Nexus 5 and Nexus 5X. You may find a way to install Play Store on other images, e. g. from GApps, but I avoided that hassle.

Important: before you build a version to officially release to PlayStore, remember to revert the above changes! You don't want to make it too easy for hackers/pirates ...

Sources:
https://stackoverflow.com/questions/11068686/this-version-of-the-application-is-not-configured-for-billing-through-google-pla
https://stackoverflow.com/questions/36113347/is-it-possible-to-debug-locally-google-plays-in-app-billing-in-android-studio
https://developer.android.com/google/play/billing/billing_testing
adaxas Web Directory