Webhooks on localhost - php

I am creating a payment gateway using Paymill (which is comparable to Stripe). I want my website to automatically react to subscription-based billings. This is why I am considering Paymill webhooks.
I am in the testing phase and thus on localhost (XAMPP). The receiving webhook script would therefore have this URL:
localhost/paymill-example-php-subscriptions-master/src/Paymill/LlamaKisses/Controllers/WebhooksController.php.
But is it possible at all to set a localhost address as a webhook url (and how)?
(By the way, isn't WebhooksController.php missing a response code line like this:
http_response_code(200);
to let the sending webhook know it succeeded and needn't retry?)
Many thanks in advance!

Use one of these tunneling apps:
http://john-sheehan.com/blog/a-survey-of-the-localhost-proxying-landscape

You can use Webhook Relay (https://webhookrelay.com) to create webhook forwarding tunnels or bidirectional tunnels:
$ relay forward -b webhook-demo http://localhost:8090/webhook
Forwarding:
https://my.webhookrelay.com/v1/webhooks/5e722a5e-f3d2-4hqec-9e9f-79f1158e4b10 -> http://localhost:8090/webhook
starting webhook relay agent..
Endpoints are permanent (until you delete them) and it is also possible to fan-out webhooks to more than one destination.
.

I am using Azure Websites with a Free mode website. With that you can attach remote debugger to the Azure Website and if I am not mistaken you can do that with free tools from MS too. You can easily switch on tracing to Azure Table storage or file system and from within a webbrowser or tools look at logs. It may not be apt for you, but if you have a bit of time to play around it's quite easy. I am logging the whole PayMill webhook message to an Azure Table .

Related

Is there is any way to serve my php app from computer to whole internet?

I am a PHP developing a PHP telegram bot in my VPS. Whenever I have to change something in code I have to first open the file and then edit it then reload the server to see the effect of the changes it's a lot to do is there is any simple way?
I can not use localhost of my computer here because telegram API send me updates through post request every time a user uses my bot, therefore telegram can not send it to HTTP:localhost:3000
I also tried polling (checking telegram API every second for updates) but telegram throw me a timeout error that way.
so if you have any idea please share with us
To make your IP visible to the internet you should use a technique called Port Forwarding.
Because you haven't mentioned what kind of router you use to connect to the internet I'm not able to write any examples on this.
I suggest you stick to getUpdates method (which is long polling as you said). To make sure you have access to telegram bot api server, open your browser and visit this link (Replace your bot token in the link):
https://api.telegram.org/bot[YOUR_BOT_TOKEN]/getUpdates
Replace [YOUR_BOT_TOKEN] with your own token. If it works and doesn't give you a timeout error, that means you're using a wrong link in your script or the library you're using has issues.

PHP Bitcoin wallet/transfer interface

First, I need to tell that I'm pretty new about Bitcoin.
I'm asked to build a Bitcoin Exchange website. I'll have a server which I plan to build with Linux and PHP.
-All the transfers will be issued manually
So we will have an online wallet and we will manually transfer Bitcoins to given addresses also receive Bitcoins to this wallet.
The problem is I'm not allowed to use any 3rd party API.
So how can I create an online wallet without any 3rd party API on my PHP server?
Should I install bitcoind to my server or is there any other way?
Is it a good idea to install bitcoind to a remote server?
Thanks.
The problem is I'm not allowed to use any 3rd party API.
It is good decision to make your system safe, but it is not enough.
Should I install bitcoind to my server or is there any other way? Is it a good idea to install bitcoind to a remote server?
With any approach, you need a bitcoin node (which bitcoind is most reliable one) which be accessible with you PHP code, so it should be remote!
I don't think it would be a security problem to install bitcoind on your PHP server, as long as it would be configured to just listen to localhost and not visible publicly, and just respond to your server PHP requests.
But don't forget that there are still many other security risks here.
For example if someone be able to hack your server and access it, he can easily use your funds. It is best practice to implement a Cold Storage solution to transfer most part of funds in your hot online exchange wallet to it, and bring it back to hot wallet manually whenever it is needed.

How to capture the actual data that is being transfred between Web Server and WebService

I wrote PHP code that allows me to communicate with a REST API.
My PHP call issues a cURL call to communicate with the API service. However, I am running into a weird issue where the data that is being received by the API is not what is being sent using cURL.
I would like to setup some type of a middle man to ensure that the request that I send to from Apache is the same data that is received by the API.
The information that I am interested to see is
Request/Received Header
Request/Received Body
I am thinking about ruining Wireshark on the Apache server to capture the packets that are going from my Apache to the API and also everything that is being received from the API to Apache.
After installing Wireshark on the Apache server "a Windows 7 machine" I see a lot of data.
How can I tell Wireshark to only capture the data from Apache to the API and from the API to Apache only?
Thank you for your help.
There are many tools for API tsting, starting from very easy to use browser plugins and finishing with someting quite complicated as Apache Jmeter. The idea is to make the calls from your testing software to the API and analyse the request and response. if you are on windows you can use something like Fiddler to intercept the packages that are going out from your machine. If you have access to client server I assume there are tools for various OS to intercept the outgoing packages and analyse them, but you would have to google for those.
to filter HTTP results in Wireshark, just type http in the filter field and click Apply
to have a better look, just start th capture before the HTTP request and stop it juste after
afterward, if you know the IP of the API server, you can filter a step more with :
http && ip.dst == X.X.X.X

CURL request for AZURE Push Notification is not working

I have gone through links that provide some CURL request samples for AZURE push notifications but none of them works for me.
Like in this url CURL request using Ruby language is provided but like others it is also not working.
"Internal Server Error (500)"
occurred every time when I made a request using CURL requests.
If anybody can provide me with working code of CURL request for AZURE push notifications then it would be convenient for me to solve the issue. Keeping in mind that push notifications from web portal of AZURE are working absolutely fine.
May I know whether you are using Azure Service Bus Notification Hub? If so, the most likely problem from my experience is you may haven't formatted the request properly. It’s needed to prepare the following information, and send them in request headers:
Content-Type: Based on the platform you choose, the value will be different. For instance, for Windows Store apps, content type is application/xml.
ServiceBusNotification-Format: The device type, such as windows.
X-WNS-Type: Push notification type, such as wns/toast.
Authorization: The rules are described in https://msdn.microsoft.com/en-us/library/azure/dn495627.aspx. Pay special attention to the Create SAS Security Token part.
And the request content. The format is different for different devices. For example, for Windows Store apps, it’s needed to use xml like:
<?xml version="1.0" encoding="utf-16"?><toast><visual><binding template="ToastText01"><text id="1">Hello!</text></binding></visual></toast>
If you're using CURL command line, please make sure to use double quotes instead of single quotes.
Also please make sure you have correctly registered the push notification service provider in Azure. For instance, for Windows Store apps, please register the SID and the client secret.
If the issue is still encountered, please share more information. It would be better if you can let us know:
• Are you trying to use the CURL command line or PHP code?
• What kind of device you're using?
• What kind of message you want to send?

Making Android chat application from scratch

I need to make chat application for android. I thought of using PHP script to implement the chat application. Basic idea is to send message form android client to PHP script and making use of PHP script send the messages to the MySQL database. These messages will be broadcasting to other people. But the problem is auto broadcasting messages to other people. Is there a way to do this using android and php?
You can do the following
Make a persistent tcp connection between your device and the PHP server
When a message is broadcast send it over the tcp connection of each device
On the device process this notification and you are good to go.
If you want to use Java on the server side I have your project already finished and ready to ship ;) (just kidding)
But if you are interested check out the Device-To-Device messaging framework of OpenMobster Mobile Cloud platform. The project is free and open source. Here is a link to the Device-To-Device Framework: http://code.google.com/p/openmobster/wiki/D2DPushFramework
and http://code.google.com/p/openmobster/wiki/PushFramework
The above three steps are already taken care of by the framework. The developer just has to focus on the App itself
Good Luck!!!!
Yes there is several ways to do this
you can just post to the server and from the server send push notifications to the mobiles
You can make the mobile keep checking for updates if it exists
You will require to finish these steps ( at least ):
setup a PHP web server
register for Android Push Notification (you probably need that)
create database schema
write your own codes to allow users to submit & retrieve chat messages
security !!!
You'd probably want to use Google's C2DM, though it's not free.
Your php server would get a message from a phone, do it's processing, then make a HTTPS request to Google's C2DM service, which sends the messages to the destination android device.
http://code.google.com/android/c2dm/#push-process
Don't use C2DM, its a deprecated. Please go through the GCM(Global Cloud Messaging),
please follow this link,
http://developer.android.com/google/gcm
Have you heard of Firebase? Firebase. Making a chat app with Firebase is like eating pizza.

Categories