President Trump and UN Ambassador Nikki Haley’s warnings that Washington would take action against nations that oppose the United States in the General Assembly clearly had their intended effect.

Yes, Thursday’s vote declaring Trump’s recognition of Jerusalem as Israel’s capital “null and void” was predictably lopsided: The final tally was 128-9.

But 35 nations abstained, including five members of the European Union who broke with the EU consensus and several in Latin America. Another 21 nations just didn’t show up for the vote.

That’s far more than were originally expected before Haley warned that “the US will be taking names.”

After all, the nonbinding resolution was aimed as much at America as at Israel: Without naming Trump, it called for recent decisions on Jerusalem to be “rescinded.”

This when, as Haley noted, America has been paying the lion’s share of the UN budget ever since its founding. Without the US and its aid, there is no United Nations.

And, as she also stressed, “when a nation is singled out for attack, that nation is disrespected” — especially when it’s then called on to pay for the “privilege.”

So the United States “will remember this day when it was singled out for attack,” particularly “when so many countries come calling on us, as they so often do, to pay even more and to use our influence for their benefit.”

Such blunt talk, hearkening back to such outspoken ambassadors as Daniel Patrick Moynihan and Jeane Kirkpatrick, was long overdue.

It sends the important message that Washington won’t tailor its policies against its own interests in the name of international consensus and avoiding confrontation.

Americans — who, after all, pay the bills — have a right to expect, as Haley said, that “our good will is recognized and respected.” And those who refuse to do so can expect to face the consequences.