My Ah Gong and Ah Seng Story – A Response to Lee Bee Wah’s BS

Ah Seng always gives money to Ah Gong. Everytime Ah Seng buys things at a shop, Ah Gong gets 7%. Ah Seng smokes and drinks occasionally, so for that privilege, Ah Seng gives Ah Gong a bit more.

Every year, Ah Seng pays a portion of what he earns to Ah Gong. This excludes the 40% (20+20 CPF) he gives to Ah Gong for safe keeping.

Ah Gong takes that 40% and invests it on Ah Seng’s behalf, and promises Ah Seng will get it back at 60. No, 65. Wait, it’s 67? Ah Seng doesn’t know when he’s getting back the money.

Ah Gong pays his henchmen millions of Ah Seng’s money for their “talent”, and gives Ah Seng peanuts. The peanuts get bigger toward the end of each 4 year cycle.

Ah Seng shouts and screams to get his money back, but Ah Gong just “lol”.

Not forgetting, Ah Gong’s million dollar henchmen tells Ah Seng that picking up cardboard in old age is “exercise”.

Ah Seng can’t wait to dump Ah Gong, but Ah Gong just refuses to die.

Water words – Resource Traded for over 70 Years, by Janadas Devan

A short preface from SgOkay:

TLDR; Singapore used to get water for Malaysia for free (1927 – 1960), paying M’sia only for the land used. S’pore has paid M’sia a huge sum of money upfront (320 million ringgit+), and the Johor administration continues to turn a 25 million ringgit profit every year by reselling treated water to her residents.

I like to think that the water agreement has been beneficial to both parties, and both the water, and the money have been vital to each country’s growth, and Dr Mahathir’s claims that M’sia is at the losing end unfairly make Singapore the scapegoat for the failings of Malaysia’s past and present administration.

(This article below is a direct reproduction of a Facebook post made by Janadas Devan, Chief of Government Communications at the Ministry of Communications and Information of Singapore. See original source at bottom of page)

“Some treaties might be so fundamental to the very existence of States that they simply could not be dispensed with, whatever political differences might arise. For example, the new island State of Singapore was dependent on Malaysia for its water supply; the treaty under which Malaysia had to supply a certain quantity of water daily to Singapore could not be terminated or suspended between the two states for any political reason.”

THERE is no more succinct statement defining the unique centrality of the water agreements between Singapore and Malaysia than the above. Astonishingly enough, the statement was made not by a Singaporean, but by a Malaysian official — Mr M.O. Ariff, at the United Nations Conference on the Law of Treaties in 1968.

Since then, there have been four Malaysian and two Singaporean prime ministers. Significantly, not a single one of them has ever contradicted, in either word or deed, the import of Mr Ariff’s statement.

To understand why, one needs to consider not only the water agreements themselves, but also their unique place in the Republic’s founding document, the 1965 Independence of Singapore Agreement, as well as in Malaysia’s Constitution.

In the wake of the Singapore Government’s Jan 25 release of documents, including copies of the water agreements, our senior writer JANADAS DEVAN pored over the material to find out what they say.

 – – –

THERE have been four water agreements – in 1927, 1961, 1962 and 1990, with the last three still in force. The first is now a historical curiosity, the second and third were guaranteed in the Separation Agreement and lodged with the United Nations, and the fourth concerns the building of the Linggiu dam and Singapore’s purchase of treated water from Johor.

The 1927 agreement

THIS was between the municipal commissioners of the town of Singapore and the Sultan of Johor. Both Singapore and the Malayan states were then British colonies or protectorates.

The agreement allowed the municipality of Singapore to rent from Johor 2,100 acres in the Gunong Pulai area, for 30 cents per acre annually.

In addition, Johor set aside about 65 sq km, promising not to alienate any part of this land without the consent of the Singapore commissioners. On their part, the commissioners were to give notice to Johor if they wished to reserve any part of this larger plot for drawing water, paying $5 per acre annually.

Johor was entitled to draw 800,000 gallons of treated water daily from the Singapore municipality, and paid 25 cents for every 1,000 gallons. The municipality, however, did not pay Johor for the raw water it drew.

So Malaysian politicians, such as Prime Minister Mahathir Mohamad, who claim that Singapore has been paying 3 sen per 1,000 gallons of raw water since 1927 are wrong. Johor did not charge colonial Singapore for the water. It collected only the rental on the land the municipality used. In return, Johor paid nothing to build or maintain the waterworks, dams, pipelines or reservoirs which supplied it with 800,000 gallons of treated water a day.

The 1961 agreement

THIS was between the City Council of Singapore (the predecessor of the Public Utilities Board) and the Johor Government. By then, Singapore was a self-governing country, with Mr Lee Kuan Yew as its Prime Minister, and the Federation of Malaya was a fully independent state, with Tunku Abdul Rahman as its Prime Minister. Contrary to what Malaysian leaders often claim, the British had nothing to do with this or later water agreements.

The agreement set aside land in Gunong Pulai, Sungei Tebrau and Sungei Scudai for a period of 50 years, giving Singapore ‘the sole and absolute right to draw off and take all water available in under or upon any part of the land’ or ‘any river in under or upon’ the specified area till 2011.

Singapore agreed to pay a rental of $5 per acre per annum for the land, and a charge of 3 cents for every 1,000 gallons of raw water it drew. (Singapore and Malaya then had a joint currency, but when the currency was split in 1973, these sums became denominated in Malaysian ringgit and sen.)

Johor could draw from Singapore at least ’12 per cent of the total quantity of water supplied to Singapore’. It could draw more if the 12 per cent proved ‘inadequate’ to meet the needs of Johor – a provision the state has taken full advantage of, as we shall see shortly.

Johor agreed to pay 50 cents (later 50 sen) per 1,000 gallons of this treated water.

Clause 2(ii) of the agreement states specifically that Johor ‘shall not at any time do any act or deed which might in any way prejudicially affect the interest’ of Singapore under the terms of agreement.

Clause 7 gave Singapore the full power to ‘occupy and use the said land’ to construct and maintain waterworks, reservoirs, dams, tanks, pipelines, aqueducts, filters and any other necessary building or plant.

On expiry of the agreement in 2011, none of these facilities will be demolished, and Johor can presumably acquire them.

The 1962 agreement

THIS resembles the 1961 agreement in many respects, including in the key provision that Johor ‘shall not at any time do any act or deed which might in any way prejudicially affect the interests’ of Singapore under the terms of the agreement.

The chief differences are that it specifies a longer time period – 99 years, expiring in 2061 – and a new source: the Johor River.

Singapore was required to pay rent on the land it used ‘at the standard rate applicable to building lots on town land’, and it was given ‘the full and exclusive right and liberty’ to draw up to a maximum of 250 million gallons per day (mgd) from the river, at 3 cents (later 3 sen) per 1,000 gallons.

Johor could purchase 2 per cent of this total for its own use, paying 50 cents (later 50 sen) per 1,000 gallons of treated water.

In all, the 1962 plus 1961 agreements entitled Singapore to draw about 350 mgd of raw water from Johor, which, in turn, was entitled to purchase about 15 mgd of treated water from Singapore.

Johor, however, has consistently drawn more – on average about 37 mgd, or about 22 mgd more that its entitlement – which it then sells to its residents at an average price of RM3.95 per 1,000 gallons.

This means the Johor government makes a clean profit of RM3.45 on every 1,000 gallons. At the rate of 37 mgd, this profit works out to RM46.6 million per annum.

On Singapore’s part, since it costs PUB about RM2.40 to treat 1,000 gallons of raw water, the Singapore tax-payer has in effect subsidised Johor at the rate of RM1.90 per 1,000 gallons, or RM25.7 million per annum.

The 1990 agreement

THIS was supplementary to the 1962 agreement, and will also expire in 2061. The agreement was between the PUB and the Johor state government, but both the Malaysian and Singapore governments guaranteed it.

Dr Mahathir was Malaysia’s Prime Minister when this occurred, while Mr Lee was still Singapore’s.

Significantly, the 1990 agreement reaffirmed the 1962 deal, since it refers in its preamble to Singapore’s right to draw water from the Johor river ‘subject to the terms, provisions, conditions and stipulations’ of the earlier agreement.

In effect, when Kuala Lumpur guaranteed the 1990 agreement, it reaffirmed, among other things, the prices stipulated in 1962.

The 1990 agreement allowed Singapore to construct, ‘at her own cost’, the Linggiu dam across the Johor River. ‘In consideration’ of this, Singapore was allowed to buy from Johor treated water generated by the dam and its ancillary works, over and above the 250 mgd of raw water that it was already entitled to draw from the river under the 1962 arrangement.

The 1990 agreement specifies a formula to determine the price of the treated water. Singapore would pay whichever of the following was higher:

  • ‘The weighted average of Johor’s water tariffs plus a premium which is 50 per cent of the surplus from the sale of this additional water by PUB to its consumers’ after deducting Johor’s price and the PUB’s cost of distribution, or
  • 115 per cent of the weighted average of Johor’s water tariffs.

Under the terms of the agreement, Johor owns the Singapore-constructed Linggiu dam, while the PUB owns the water treatment plant and ancillary works, until such time as the agreement expires in 2061, when everything built under this agreement will revert to Johor.

Johor set aside land totalling approximately 21,600 ha for the project. The PUB agreed to a premium of RM18,000 per hectare and an annual rent of RM30 for every 1,000 square feet.

In addition, it paid Johor RM320 million as compensation for loss of use of the land, as well as a ‘one-time up-front payment’ for the leasing of the land, ‘inclusive of rentals for the remaining tenure of the 1962 Johor River Water Agreement’.

According to Foreign Affairs Minister S. Jayakumar, Singapore has spent more than $1 billion on the Linggiu project. It might not have done so if the price of raw water had been revised in 1986 and 1987.

The original post:

More than 16 years ago, when we were arguing with the Malaysian govt about the water agreements, I wrote many articles…

Posted by Janadas Devan on Sunday, March 10, 2019

SingPost debacle underscores the larger underlying problem of privatization

Over the past few weeks, SingPost has come under increasing scrutiny for failing to perform its core job. Not delivering parcels to the doorstep,
leaving delivery notes without knocking, and even throwing letters away without delivering them.

One or two isolated incidents can probably be attributed to individual staff misdemeanor, but a string of incidents lead one to believe that there is something else going on.

Heavy workloads and low pay

Probably his first meal/break of the day while on the job.You can condemn Singapore Post for all their inefficient…

Posted by Amirul Azam on Thursday, February 21, 2019

As Amirul has succinctly put it, we should appreciate the work put in by our postmen and women. They take their breaks when they can, and deliver backbreaking amounts of mail.

Given the increase in popularity of online shopping, the number of parcels they have to deliver in person, have presumably increased exponentially. In the past, maybe there would be one or two parcels a block. Now, maybe ten to twenty. This difference is huge.

A postman’s median salary, according to Ministry of Manpower (MOM)’s Benchmarking Occupational Wages webpage, is $1,540 (based on 2016 figures). At the lower end of the spectrum, they could earn as little as $1,000 a month.

Reproduced from TOC’s article

With such low salaries, and difficult working conditions, it is no wonder that SingPost has found it tough to hire locals.

The bigger question. Should public services be privatized?

SingPost’s failure in their core service, as well as the MRT breakdowns in pre-2018, simply show that the privatization of public services does not work. Also, recall the fiasco where public hospitals sought to attract foreign patients, leading to a shortage of beds.

Because they have shareholders to answer to, and CEOs to pay millions to, their attention is shifted away from the core service that their organization was founded to provide. Instead, they now have to ensure KPIs are met, a large number of which are unrelated to their core service.I

In my personal opinion, public services should not be profit driven. They should be a cost to the country. Why?

We all pay taxes. The rich pay more, the poor pay less. Often, the poor use public services (eg. public transport, postal services, and healthcare) more than the rich. To put it bluntly, the rich subsidizes the less-well-off.

As such, while there should not be frivolous spending of public monies, it isn’t right to simply privatize these companies and force them to “find money”, government subsidies or no.

We now have evidence that this model does not work well.

How would a non-privatized SingPost be different?

Right off the bat, postmen would be civil servants, with access to more reasonable pay and benefits. Sure, it would be at a greater cost to the governement, but they wouldn’t need to pay the CEO 2 million dollars a year.

This sum, split across 3,000 (estimated) postmen, would mean each would receive an additional $55 a month. Don’t forget, we still haven’t counted the savings from not paying a board of directors.

Off-tangent: The recent opening up of the electricity market seems to be another push to further privatize a public service, one that may not benefit consumers in the long run. We shall see.

“Dum dum dum, another one bites the dust”, ofo licence suspended

“Dum dum dum, another one bites the dust, …”

The Land Transport Authority (LTA) has suspended ofo’s licence to operate their bike sharing service here, effective today (14 Feb 2019). Source

In a statement released by LTA, “Despite previous communications with ofo to comply with the regulatory requirements by Feb 13, 2019, ofo has failed to comply with these requirements, including proper implementation of the QR code system”.

Due to suspension, ofo now has 1 month, until 13 Mar 2019, to remove all their bicycles from public spaces. I wonder if this is even possible. Back in November, LTA served ofo their Notice of Intention to take regulatory action for not complying with the maximum fleet size.

Oddly, while LTA had granted them a licence for 25,000 bicycles, ofo had requested that number be reduced to 10,000. At present, they still have more than 25,000 bicycles, which is one of the reasons why LTA is taking action. Source

There is a possibility the suspension could be lifted, if ofo can meet the regulatory requirements stipulated in the licence. Depending on their efforts made to comply, their licence could be canceled.

Fingers crossed. I’ve not used bicycle sharing services in awhile, thankfully. What about you? 

Friends will be moving out of Netflix this year

The comedy was acquired by Netflix for a cool $118 million back in 2015 is moving to an unnamed WarnerMedia streaming platform. Source

Friends is currently the third most popular sitcom on Netflix in the US, and it’s removal from the service is a huge blow to their offerings.

Besides that, more companies are coming up with their own streaming services, notably, Disney, whose content includes the following notable ones:

  • Star Wars
  • The Muppets
  • The Marvel Cinematic Universe
  • Disney Princesses/Princes (eg. characters from  Aladdin , The Lion King , Mulan, Frozen, and Cinderella )
  • The Chronicles of Narnia Franchise
  • The Pirates of the Caribbean Franchise
  • Pixar Films (such as Toy Story, The Incredibles, and Cars)
  • The Winnie the Pooh Franchise
  • The Indiana Jones Franchise
  • Grey’s Anatomy (and other popular ABC shows)

The reason why Netflix was so successful was because it consolidated a large number offerings from many different companies onto one platform, for one fee. Other companies now wanting a slice of that pie, could very well end up unmaking the whole damn pie.

At the end of the day, consumers suffer. Could this spell the start of the end of the popularity of streaming services?

Deliveroo sneaks in additional charges

Customers of Deliveroo’s food delivery service have noticed additional fees being snuck into their bills during checkout, in the form of a “small order fee”. The fee of up to $5 is charged for orders under $10. The change comes no more than six months after Deliveroo removed their minimum $12 spend for delivery to most parts of Singapore.

On one hand, such a charge is understandable, as the company has to make money somehow. On the other, to not announce the new fees in a forthcoming way is an unacceptable way to do business.

Netizens respond:

The supporters (Deliveroo riders maybe?)

The logical and practical ones:

The ones who support the riders:

Deliveroo responds:

Mr Siddharth Shanker, general manager for Deliveroo Singapore, said in response to queries that the “variable fees” are tied to the service’s expansion.

No one likes paying additional fees, but Deliveroo should’ve been more upfront about it, IMO.

What do you think?

Training incidents and accountability – Who should hang?

About two weeks ago, I wrote “Aloysius Pang – Is National Service the problem?“, and took a stab at explaining some of SAF’s safety precautions.

Yesterday in Parliament, Defense Minister, Dr Ng Eng Hen said that MINDEF, and the SAF, will align their “incentives and disincentives (on safety), so we get the whole system moving”.

This was in response to Non-Constituency Member of Parliament (NCMP) Dennis Tan, who had asked “At what point, and at what stage, would the Government think it would be necessary to send a signal to the entire force when they recognise there might be a problem at the systemic or greater level, requiring a senior officer, whether at formation, army, SAF, or beyond, to take responsibility for all this?”

We also have a lot of vocal members of the public who want Ministers, and senior leadership to take responsibility for the accidents that occur. Of course, in this case, I assume “take responsibility” would mean to be court martialed, step down from current position etc. After all, COA, CDF, and Dr Ng has already accepted responsibility for the incident.

Let’s take a look at what this means. First, take a look at the chain of command in a typical infantry unit. (Things get fuzzy after Battalion CO, so let me know if you spot any glaring mistakes)

Typical chain-of-command in an infantry unit

Accidents usually happen at the lowest levels, i.e. the men (recruits, privates, corporals) and section commanders. We form the largest group of our army. We are the kah-kias, the sai-gang warriors, so to speak.

In an Operationally Ready (OR) Battalion like Aloysius’, everyone below the Battalion CO (in a more mature Battalion, this includes the Bn CO himself) are NS men. Yes, they’re just there to serve their time and FO (eff-off) back to their families after the week or two each year.

Yes, out of the 10 layers of command, half of these are NS men, just like Aloysius. If we are to, for example, hold the Minister responsible for a training fatality, we should go after everybody in between, no?

If there is evidence of a systemic failure to ensure safety standards were adhered to, yes, everyone who was involved in the lapse should be taken to task. In most cases, this is simply not the case.

My other gripe with this issue is that when people transit into civilian life, and come back for NS, they find ways to siam (dodge) stuff they find meaningless.

Here are some examples:

Cmd: Guys let’s do a water parade. Drink half a bottle.

Guy: Don’t need la sergeant, you think we still recruit meh?

Cmd: Guys, we’re going to do a FBO march to condition ourselves for the outfield training

Guy: (Puts pillow in fieldpack)

Cmd: Guys, tighten your bootlaces

Guy: Don’t want. Later got blister lah.

(Later twists an ankle)

Cmd: Guys, wake up for breakfast as 0630 hrs

Next morning –

Guy: F**k it, I’m gonna sleep in
(Faints from low blood sugar during training)

Ladies, you know how we men can act like children sometimes? Some guys actually behave that way in camp all the time.

NOTE: I’m not claiming any one training incident arose from such incidents, just stating that this is commonplace in reservist units.

The problem with the reservist model of training is the mentality that “I’m a civilian, what can you do to me?”, and “You tekan (punish) me, I chao-geng lor”. Chao-geng means to feign injury or illness in hokkien.

When faced with these types of situations, the commander in charge of performing these specific activities can only shrug his shoulders and hope nothing bad happens. You know that “At least I’ve covered my backside,” attitude? There’s really nothing more he can do.

What, you want to court martial someone for not drinking water ah?

In my own response to NCMP Dennis Tan’s question on when it would be necessary for a senior officer to take responsibility for a training incident, it is in my opinion that it should only be when said officer has either been found directly negligent, or when he has advocated for training that ignores established training standards.

Elections are coming

All the signs point to it. The opposition is stirring, the PAP is also moving, and the Big G is mobilizing the election guys for training and what not.

Dr Tan Cheng Bock, and the new PSP

Dr Tan Cheng Bock has applied to the Registry of Societies on Jan 16 for his new Progress Singapore Party (PSP). A rather unfortunate collision of acronyms with Playstation Portable, but the name has a rather nice ring to it. It is time for Progress, isn’t it? But I digress.

His application is pending approval (processing time of up to two months). As part of the application process, the party has to list down who its office-holders and other members are.

And they are:

From left, Mr Anthony Lee, 39, assistant secretary-general; Mr Wang Swee Chuan, 68, chairman; Mr G K Singam, 81, vice-chairman; and Mr S Nallakaruppan, who is in his 50s, party treasurer. Source: todayonline.com (Learn more about the founding members here)

Dr Tan recently held a CNY gathering at his place, where many Opposition members gathered, presumably to give the PAP a run for their money.

Thanks for the invitation to my family and friends to your #ChineseNewYear open house Dr & Mrs Tan Cheng Bock. Good food, better company! #Huatah!

Posted by Ravi Philemon on Wednesday, February 6, 2019

Lee Kuan Yew must be stirring in his grave.

The Ones In Power

And then we have Lee Hong Chuang, the PAP candidate who lost in Hougang SMC, doing his CNY rounds back in Hougang. He was at
Poh Teck Siang Temple, giving out goodie bags to the elderly.

Distributing food rations and red packets to #Hougang residents and friends after the morning breakfast at Poh Teck Siang Tng 【報德善堂】Bao De Shan Tang wishing them a prosperous Chinese New Year. – LHC

Posted by Lee Hong Chuang 李宏壮 on Tuesday, February 5, 2019

There’s been some debate online as he is also a grassroots leader, using grassroots funds, to increase his exposure to residents. Nevertheless, the residents here are the winners, so no complaints there.

Upcoming election

The next General Election has to be held before 15 Jan 2021, but it is likely that we will see it much sooner than that. There have been some rumblings that indicate the elections will be held this year, but we’ll see.

We will be discussing (our opinions) in upcoming posts:

  • What the current Government (PAP la) has done right
  • Where they have failed to meet our expectations
  • How worthy is the Opposition

Give our page a Like and follow us to get notified of these articles as they come.

Man wants to sue parents for giving birth to him

An Indian man has decided to sue his parents for giving birth to him. Whaaat?

Yes, this man, Raphael Samuel, claims that his parents did not ask him for permission to be born. Unbelievable? Watch the video:

This act raises many questions, most prominently, WHO has ever given permission to be born? While I’m sure many of us at some low point has asked the question, “why was I born?“, or “why was I born to these parents?” etc, I doubt anyone has actually sued their parents for bring them into the world.

What does his parents think of this? His mother responds:

The mother speaks!I'm Raphael's mother and this is my response to the recent upheaval my son has created :1. I must…

Posted by Raphael Samuel on Tuesday, February 5, 2019

First things first, wow. His parents are both lawyers. He wants to sue two (2) lawyers. Well, good luck with that.

Mum was very rational about the whole affair, “If Raphael could come up with a rational explanation as to how we could have sought his consent to be born, I will accept my fault.”

She still loves her son, and is proud for him sticking to his guns, “… very happy that my son has grown up into a fearless, independent thinking young man. …”

She also explains that “his concern for the burden on Earth’s resources due to needless life, (and) his sensitivity toward the pain experienced unwittingly by children while growing up” is what prompted him to do this.

Wow. Just wow… I suppose if he succeeds, we can go ahead and sue our parents too then. After all, no one asked to be born. 😂

Clash of Clans – How to use the Web API

I originally wrote this on my site, https://blog.crazy.technology, which I will be taking down in a few days.

This post will cover the basics to make API calls to COC from a web server.

Where there are code snippets included, I will try to include comments/explanations to help non-programmers follow along.

You will need:

[UPDATE from forum]: For a novice, he can simply create an account at a free provider because installing a web server on his own machine is already complicated. It will be confronted with firewall concerns and also non static ip address … In short, a free account and filezilla is much simpler by example https://infinityfree.net/

Notger

What this post does not cover:

  • Saving the data recieved from the API
  • Web site design
  • Basic programming skills

For a full working example, see my project, Clash Dash or view the source code on Github.

1. Register for a COC Dev Account

Head over to https://developer.clashofclans.com to sign up for an account if you don’t have one.

2. Get a JWT Token

A Brief Overview (skip if you just want to get it to work)

COC uses JSON Web Tokens (JWT) to authenticate calls to their Web API.

JSON

  • JavaScript Object Notation (basically a javascript object made into a standardized string)

JSON Web Tokens

  • Used to authenticate calls from you to the API server
  • You don’t need to know the specifics of these, but it is designed to be read-only on the client end. Modifications will break the token, and cause the authentication to fail.
  • Find out more from JWT’s official site https://jwt.io/

Steps

Click on your name (top-right hand corner) > My Account > Create a new key to get started.

Navigating to My Account

Enter a Key Name, Description and the IP addresses you will be using this API key from.
Get your public IP address from Google.

screen cap
Creating an API key

IMPORTANT: COC’s API authentication is tied to your IP address. Most residential IP addresses are * DYNAMIC (not static)*, meaning they change from time to time.

This also means that the token issued by COC will eventually throw authentication errors, and stop working. This happens when your ISP shuffles the IP addresses for you. You can simply create another key when that happens.

You will need to either get a static IP address or web hosting, which will not be covered in this article.

Your API key will contain the following details:

Viewing your API key

3. Making calls to the API

The documentation shows all the API end-points, but does not state the base URL outright.
It is: https://api.clashofclans.com/v1

end points
API end-points from documentation

Thus, to make an API call, the complete URL is:

Base URL (https://api.clashofclans.com/v1) + (/endpoint)

If the endpoint is “/clans/{clanTag}/members”, you will need to substitute the {clanTag} with your actual clan tag. For PHP, use urlencode($clantag) to get a properly formatted clan tag.

PHP code

The code below provides working snippet for you to use on your web server. Importantly, the following needs to be changed:

  • $token – Swap in your own token here
  • $clantag – Swap in your clan tag here

To use: Save the file with the extension ‘.php’ to the web server. (Eg. clash-example.php)

  • For Windows’ IIS, it is in C:\inetpub\wwwroot
  • For Apache (linux), it is in /var/www/html
<?php
header('Content-Type: application/json; charset=UTF-8');// sets response headers

$clantag = "#2PCCRLYP"; // Your clan tag here

$token = "eyJ0eXAiOiJKV1Q...JcwHWKQ"; // Your token here

//URL for api calls
$url_api_base = "https://api.clashofclans.com/v1";
$url_clan = $url_api_base."/clans/" . urlencode($clantag);
//Create a new CURL
$ch = curl_init($url_clan);

//Sets headers and options for CURL
$headr = array();
$headr[] = "Accept: application/json";
$headr[] = "Authorization: Bearer ".$token;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

//Executes and terminates request
$res = curl_exec($ch);
$clan_data_arr = json_decode($res, true);
curl_close($ch);

//prints out data obtained from CURL request. Remove this line and implement your own logic
echo json_encode($clan_data_arr);

Then, in your internet browser, navigate to http://localhost/{file-name}.php (eg. http://localhost/clash-example.php)

If you’re successful, the echo json_encode($clan_data_arr) should produce the following:

{
"tag":"#2PCCRLYP",
"name":"Night Warriors",
"type":"inviteOnly",
"description":"\u2b50\ufe0fLoyalty to Royalty\u2b50\ufe0f Telegram required for coleaders. Keep the environment friendly. Make both war attacks and keep your war status actively updated.",
"location":{
"id":32000006,
"name":"International",
"isCountry":false
}, 
// etc...

You are likely to run into errors when you run the script above due to missing modules/configuration. Enable error-reporting by placing these lines after the header in line 1 of the php file.

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Google your errors to quickly find out how to enable fix them.

Recommendations

Because you are likely to be serving a large group of web users, I highly recommend not to call COC’s API on page load. They block repeated calls to their servers, so you should schedule your calls at nice, friendly intervals and save that data on your own server.

Of course, if you’re simply calling one API per user action, it should not be an issue. The problem will arise if you try to, for example, get full player data for every member in the clan, all at once.

You may also run into this problem if your site receives a lot of traffic.

Some options are to save them as a file (see my Github project) or on a database. These are beyond the scope of this article, and will not be covered here.

If there is interest, drop me a comment below, give me a like or follow me on Facebook, and I will work on saving data into a database in the near future.

Cheers 🙂

Supercell Disclaimer: This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see Supercell’s Fan Content Policy: www.supercell.com/fan-content-policy.