Making a post request to pastebin returns a 302 - Moved Temporarily response

919 views Asked by At

I am doing a simple post using GM_xmlhttpRequest to post some text to pastebin. This is my code

GM_xmlhttpRequest({
      method: "POST",
      url: "http://pastebin.com/post.php",
      data: "api_dev_key=5c3***********************073a&api_option=paste&api_paste_code="+encodeURI(photo_url)+"&api_user_key=5******************************f&api_paste_name=cornered&api_paste_private=2&api_paste_expire_date=1W",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",              
      },
      onload: function(response) {
        alert("posted " + response);
      }
    });

I am getting no response in the script. To check if the post request itself is working, I used http://requestmaker.com/ and it shows that the POST request is returning a 302 response

Request Headers Sent:

POST /post.php HTTP/1.1
Host: pastebin.com
Accept: */*
Content-Type: application/x-www-form-urlencoded
Content-Length: 152

Response Headers:

HTTP/1.1 302 Moved Temporarily
Date: Wed, 10 Dec 2014 15:27:20 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d61fd0544ec1b0c284ba908367557bc7f1418225240; expires=Thu, 10-Dec-    15 15:27:20 GMT; path=/; domain=.pastebin.com; HttpOnly
X-Powered-By: PHP/5.5.5
Set-Cookie: cookie_key=1; expires=Wed, 07-Jan-2015 15:27:20 GMT; Max-Age=2419200;     path=/; domain=.pastebin.com
Set-Cookie: realuser=1; expires=Thu, 11-Dec-2014 15:27:20 GMT; Max-Age=86400; path=/
location: /index.php?e=2
Vary: Accept-Encoding
Server: cloudflare-nginx
CF-RAY: 196a7749d5c713e9-LAX
1

There are 1 answers

0
Marco Acierno On BEST ANSWER

Send your request to http://pastebin.com/api/api_post.php instead of http://pastebin.com/post.php.