1

我正在尝试使用免费资源在世界之外存储数据,现在我正在尝试在 pastebin 中制作粘贴。

当我尝试制作新的粘贴时,我在 http_response 中收到此错误:

“响应:不可接受:不支持您请求的任何内容类型。状态:406”

https://pastebin.com/doc_api上的 pastebin api 表示数据必须以 UTF-8 格式发送,因此我将 MIMETYPE 和 ACCEPT 设置为“text/plain;charset=utf-8”,但仍然出现错误。谁能想出如何克服这个错误?

// Follow the numbered steps in this script to set up and understand how this script works..


// Step 1:
string api_key = "";  //To make a paste to pastebin you must have a pastebin account. Once you have created a pastebin account go to the pastebin api to retrieve you unique api key. The pastebin api is at https://pastebin.com/doc_api. You can also click the api button at the top of the website on pastebin.com to go to the api. Look for the section that shows your unique api key like in this screenshot https://i.imgur.com/Q1ul8Th.png. For example if your unique pi key is c46e0524312gbgh103bedh1aba2zj1l3 then the line in this script should be: string api_key = "c46e0524312gbgh103bedh1aba2zj1l3"; 

// N.B: Do NOT ever give out your api key to anyone!!! If you intend to sell this script in your object make the script no mod as no one should ever see your api key. If someone accesses your api key they can create spam pastes on your account and/or delete your pastes. It is probably best not to sell this in an object because each copy of the object will create a new paste on your account. You can only have a limited amount of unlisted/private pastes on a free pastebin account. 

// Step 2:
string privacy = "2";  // Set the privacy of the paste your are going to make.
                       // Set this 0 if you want the paste to be public for everyone to see on pastebin.
                      // Set this to 1 if you want the paste to be public on pastebin but unlisted.
                      // Set this  to 2 if you want the paste to be private so only you can see it on pastebin.

// Step 3:
string paste_lang = ""; // If the text you are pasting is a programming/scripting language you can set this as the language key to make the paste highlight the program's syntax. For exmple if you want your paste to highlight in LSL the line in this script should look like this: string paste_lang = "lsl2"; 

//You can see a list of all highlighting keys on the pastebin api https://i.imgur.com/K5caEju.png

// Leave this blank if the text you want to paste is not a program/script


string paste_url = ""; //The url you get returned from pastebin when you make a paste. Leave this blank on first creating the paste. Once you get the URL to the created paste the script will tell you the URL to it. You can then copy and paste the URL to this line.
  

string paste_message;  // The  message you want to send as a paste. You will set/write this in an event or function.

integer coins;  // a variable you can paste to and get from your paste. Number of coins collected.

integer lives; // another variable you can paste to and get from your paste. Number of lives you have. 

integer goombahs; // another variable you can paste to and get from your paste. Number of goombahs you squashed.

integer koopas;  // another variable you can paste to and get from your paste. Number of koopa shell you kicked.
 





key owner;

key req;



default
{
    state_entry()
    {
        owner = llGetOwner();
    }
    
    
    touch_end(integer num)
    {
      
     ++ coins; // increment coins
     ++lives;   // increment lives;
     ++goombahs; // increment goombahs;
     ++koopas; // increment koopas;
       
     //Step 4 
     //Write the data you want to send as a paste   
     paste_message = "message=Itsa you Mario! You have " + (string)lives + "lives left. You collected " + (string)coins + "coins. Your princess is in another castle\ngoombahs="+(string)goombahs+"\nkoopas="+(string)koopas;   

     if(paste_url == "")  // This will create the new paste. Since you haven't made a paste before the paste_url is blank. So a new paste will be created and return a url to the paste.
     {
         
    //   curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=paste&api_user_key='.$api_user_key.'&api_paste_private='.$api_paste_private.'&api_paste_name='.$api_paste_name.'&api_paste_expire_date='.$api_paste_expire_date.'&api_paste_format='.$api_paste_format.'&api_dev_key='.$api_dev_key.'&api_paste_code='.$api_paste_code.'');
  
       req =  llHTTPRequest("https://pastebin.com/api/api_post.php?api_option=paste&api_dev_key="+llEscapeURL(api_key)+"&api_paste_private="+llEscapeURL(privacy)+"&api_paste_name="+llEscapeURL("test_lsl")+"&api_paste_code="+llEscapeURL(paste_message),[HTTP_MIMETYPE,"text/plain;charset=utf-8",HTTP_METHOD,"POST",HTTP_EXTENDED_ERROR,TRUE, HTTP_ACCEPT, "text/plain;charset=utf-8"],"Ping"); 


     }
     
     else // This will update the paste. Since a paste was created there is a URL to it. Delete the paste and create a new one. 
     {
         
         
         
     }
        
    }

    http_request(key reqID, string method, string body )
    {
        
        llOwnerSay("REQUEST: " + body);
        
    }
    
    http_response(key reqID, integer status, list metadata, string body)
    {
        
         llOwnerSay("RESPONSE:" +body + " STATUS:" + (string)status + "METADATA: " + llList2CSV(metadata));
        
    }
   
}
4

0 回答 0