doukai1226 2013-09-27 12:47
浏览 20
已采纳

发布使用卷曲

I am for the first time trying to us php curl. I am trying this by creating issue in Bitbucket issue tracker.

The API documentation shows below as the end point for authenticated user:

POST https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/issues  --data "title=value&content=value"

And the curl request are said to be like this:

curl -r POST --header "Content-Length: 0" -u user:pass https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/issues  --data "title=value&content=value

I am trying with the below code:

$p = 'curl -r POST --header "Content-Length: 0" -u user:pass https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/issues  --data "title=value&content=value';

$ch = curl_init();
//execute post
$result = curl_exec($point);
//close connection
curl_close($ch);
  • 写回答

2条回答 默认 最新

  • dougou1127 2013-09-27 13:01
    关注
    <?php
      //extract data from the post
       extract($_POST);
    
        //set POST variables
        $url = 'http://domain.com/get-post.php';
        $fields = array(
                                'lname' => urlencode($last_name),
                                'fname' => urlencode($first_name),
                                'title' => urlencode($title),
                                'company' => urlencode($institution),
                                'age' => urlencode($age),
                                'email' => urlencode($email),
                                'phone' => urlencode($phone)
                        );
    
        //url-ify the data for the POST
        foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
        rtrim($fields_string, '&');
    
        //open connection
        $ch = curl_init();
    
        //set the url, number of POST vars, POST data
        curl_setopt($ch,CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_POST, count($fields));
        curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
    
        //execute post
        $result = curl_exec($ch);
    
        //close connection
        curl_close($ch);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?