PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 4, 2022

[FIXED] Sending a cURL POST request as a link

 February 04, 2022     curl, django, lamp, post, python     No comments   

Issue

I have a LAMP Django API that sends out a text message to my customer which says Click [This Link] to do A and [Another Link] to do B.

I've been using POST requests to take in data to my API but that's been me polling directly from cURL in cmd. I want to create the request, then be able to send it out as a link to my client, then they click it and the post request is sent to my API.

Is this possible?

UPDATE: I have an ID number attached to each user. So this ID needs to persist from the API to the text and back to the API somehow.


Solution

You need to use something like the requests library. The only thing you need to do then is create a GET View, link your CLICK HERE so it resolves to that view, and then simply send the POST request from said View.

from django.http import HttpResponse
from django.views import View
import requests

class MyView(View):

    def get(self, request, *args, **kwargs):
        requests.post(your_url_here, data=your_body, headers=your_headers)
        return HttpResponse('POST request sent!')


Answered By - Dalvtor
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing