Twitter -- Tracking single user's tweet using API - api

I am having a hard time solving this dilemma, and I have a feeling that it's been done a million times, I just cannot find any documentation on it. What I am trying to do:
I have a button on my site that pops open a Twitter window and allows a user to tweet a reformatted message that I have defined.
<a onclick="window.open('https://twitter.com/intent/tweet?original_referer=<?php echo $_page_url?>&source=tweetbutton&text=<?php echo $tweet_message ?>&url=<?php echo $_page_url?>', '', 'height=500,width=650,modal=yes,alwaysRaised=yes resizable=1 scrollbars=1');">
<img src="/share/twitter_share.png" alt="share now" width="94" height="23" />
</a>
What I am needing is a way of tracking if this person has successfully tweeted this message and the user id or username returned for storage in a database. The reason for this is that I want them entered in this database ONCE. We are having a giveaway based on a single share/tweet, and they only get one entry per username/id.
I have tried multiple ways to retrieve the ID or username of current logged in user, mostly using the https://api.twitter.com/ to return JSON to no avail. I have also read the following:
https://dev.twitter.com/docs/platform-objects/users
https://dev.twitter.com/docs/platform-objects/tweets
And am now stuck. All I need is a return for user id that I can attach to the above window. Does anyone know how I can accomplish this? Thanks!

It cannot be done using this approach, at least not with true certainity. All you can do is track if 1) the window was successfully open using onclick and 2) if the window was closed (you can assume that perhaps the user completed the tweet).
You will NOT able to get ANY information from you open window via Javascript because the window is NOT in your domain (meaning, it is not on your server but on Twitter's).
What you want to do is implement this functionality in code as opposed to a javascript popup window. I have seen a number of commerical products that do exactly what you are describing.
The documentation (links) you provided refer to the REST API for Twitter (which usually works on the server) that is VERY different from Twitter's Web Intents which is client site javascript plugin, which has no similar API.

Related

How can I get an url to a statement using a Chargify API?

How can I get an url to a statement using a Chargify API?
I want a user to be able to click a button in my application which would open an invoice in a new tab in browser in Chargify. I think I should use some Chargify API to obtain the url to open. Could someone help me find the API I need?
I tried to search for a needed API here, but with no success so far.
I was only able to figure out how to retrieve an invoice as a plain text, as a basic html and as a usual html here. Does it mean that Chargify expects me to only show invoice to a user inside my application and not inside chargify itself?
There is no publicly accessible url for a statement. As you noted, you can retrieve the text or html (or pdf I think?) representation of it and display that to your user.
Or (if it is enabled) customers can go to the Billing Portal to view their statements. https://help.chargify.com/settings/billing-portal.html
(The newer Relationship Invoicing platform does have public urls for the invoices. https://help.chargify.com/invoices/differences.html )

How to store custom user data on Netlify Identity?

I've been using Netlify for storing 100% of my app (both frontend and backend) for the last three months. So far, so good.
The only problem now is that I need to store a custom property for each user (say, the phone number), and apparently Netlify Identity doesn't support this (only email, name and roles https://www.netlify.com/docs/identity/).
I don't want to change the whole app to migrate to another hosting provider just for this detail (actually, I can't, it's for a client and I just don't have time), because it works great, but at the same time I need it.
Can you think of any workaround to this? The less "hackish", the better, but I understand that I'm going beyond the intended use of Netlify Identity.
So it actually does look like Netlify's GoTrue API has a specific endpoint for updating custom user data. After a user is created, you can update metadata by including it as "data" within an authenticated PUT request to /user.
PUT /user
{
"data" {
"custom_key": "value",
}
}
See https://github.com/netlify/gotrue for more info.
There are dozens of ways to do this, so I'll talk about two generally applicable ways now:
the most "generally capable" one is probably using lambda functions: https://www.netlify.com/docs/functions . This lets you run dynamic code, such as "store to database hosted elsewhere" or "email to our office manager to update a spreadsheet" or even "commit to our closed git repo so it's available in-code" (last one is probably a worst practice, but is possible). You can similarly use a function to read that data back out without exposing API tokens (code example: https://github.com/netlify/code-examples/tree/master/function_examples/token-hider)
you could have the data gathered via a form submission (https://www.netlify.com/docs/form-handling). I'd probably use zapier.com to receive a notification of the form submission (https://www.netlify.com/docs/form-handling/#notifications). Zapier can of course connect to just about anything on the planet :) . Getting the data back out if you want to show it in your UI is a bit more of a challenge, but you could use the above mentioned functions if you need to connect to some private data store to pull it out. Or for an MVP, just not show it, only let people enter/update it ;)

Send an initial message when people first invite the Telegram bot

I am using Python and have previously built Telegram chatbot before.
However, now I want to create a chatbot such that when someone invites it, it will send an initial message that says something like "type /start for instructions".
This is to make sure that they know what to do when they first invite the bot. Can this be possibly done?
I am trying to use bot.send_message(chat_id=chat_id, text="type /start for instructions") but the problem is I don't know how I could obtain the chat_id.
Unfortunately, you cannot do it :(
Here has another way you might interested: /setdescription in #BotFather.
It will be shown in the What can this bot do? section as the picture below.
After digging this issue - here's what I've found:
The reason:
Intuitively it seems logical to allow a feature that sends a message to a user (as a reaction to the user's action for starting the chat). BUT, because telegram APIs are truly vast there is a fair chance for abuse in this format (a message with button that drives the user for action without the user truly understand the consequences). From here my question changed from "how to implement this mechanism?" to "Which alternative do I have?"
There is an alternative!
My initial goal was to make the "what can I do here" factor as clear and effortless to the user as possible. Technically speaking - all methods that can be invoked without the chat_id can be invoked as part of your bot setup process and will affect all users. One option is to create a list of commands to your bot. This list will appear when the user use the / operator and it's a common practice among chat users. For my intention - I needed something even simpler than that and I think that the setChatMenuButton is very suitable. This method allows you to create a web app and allows the user to simply click it instead of typing text. When clicking the button it triggers a dialog that clarifies to the user what's going on and from there - it's basically your imagination that will define how the end-user will experience your process. I managed to execute this call using a wrapper that I've build (which handles the base url as well as secret key) using this code:
await api.get('setChatMenuButton', {
menu_button: JSON.stringify({
type: 'web_app',
text: 'Name of your app here',
web_app: { url: 'https://your-domain.com/ppp/path/goes/here' }
}),
})
More about Telegram Web Apps
And a little screenshot from my experience:

Bluemix - Some bugs about virtual machines

<Bugpicture_1_1丨Bugpicture_1_2>
As you can see.I have two instances in total,but I only can control one of them.
I can't see the other one on Bluemix console either.
I wonder to know how to delete that one.
I can't terminate the instances in the secound picutre.
I had tried many times to do that.
After wating,nothing happened.And its status is error.
I don't know what should I do.
I suggest you to open a support request using one of the following methods:
Use the Support Widget. It is available from the user avatar in the
upper right corner of the main Bluemix UI. After opening the support
widget panel, select Get Help > Get In Touch , select the type of
assistance you need, and then fill out the support form.
Use the Support Site 'Get Help' form. This form is available on a separate site that is made available for ticket submission when you cannot log into Bluemix and access the Support Widget. Go to http://ibm.biz/bluemixsupport and fill in the support request form.

How do you access browser history?

Some e-Marketing tools claim to choose which web page to display based on where you were before. That is, if you've been browsing truck sites and then go to Ford.com, your first page would be of the Ford Explorer.
I know you can get the immediate preceding page with HTTP_REFERRER, but how do you know where they were 6 sites ago?
Javascript this should get you started: http://www.dicabrio.com/javascript/steal-history.php
There are more nefarius means to: http://ha.ckers.org/blog/20070228/steal-browser-history-without-javascript/
Edit:I wanted to add that although this works it is a sleazy marketing teqnique and an invasion of privacy.
Unrelated but relevant, if you only want to look one page back and you can't get to the headers of a page, then document.referrer gives you the place a visitor came from.
You can't access the values for the entries in browser history (neither client side nor server side). All you can do is to send the browser back or forward a number of steps. The entries of the history are otherwise hidden from programmatic access.
Also note that HTTP_REFERER won't be there if the user typed the address in the URL bar instead of following a link to your page.
The browser history can't be directly accessed, but you can compare a list of sites with the user's history. This can be done because the browser attributes a different CSS style to a link that hasn't been visited and one that has.
Using this style difference you can change the content of you pages using pure CSS, but in general javascript is used. There is a good article here about using this trick to improve the user experience by displaying only the RSS aggregator or social bookmarking links that the user actually uses: http://www.niallkennedy.com/blog/2008/02/browser-history-sniff.html