• <legend id='z9Ggm'><style id='z9Ggm'><dir id='z9Ggm'><q id='z9Ggm'></q></dir></style></legend>
    <tfoot id='z9Ggm'></tfoot>
    • <bdo id='z9Ggm'></bdo><ul id='z9Ggm'></ul>

    <small id='z9Ggm'></small><noframes id='z9Ggm'>

      1. <i id='z9Ggm'><tr id='z9Ggm'><dt id='z9Ggm'><q id='z9Ggm'><span id='z9Ggm'><b id='z9Ggm'><form id='z9Ggm'><ins id='z9Ggm'></ins><ul id='z9Ggm'></ul><sub id='z9Ggm'></sub></form><legend id='z9Ggm'></legend><bdo id='z9Ggm'><pre id='z9Ggm'><center id='z9Ggm'></center></pre></bdo></b><th id='z9Ggm'></th></span></q></dt></tr></i><div id='z9Ggm'><tfoot id='z9Ggm'></tfoot><dl id='z9Ggm'><fieldset id='z9Ggm'></fieldset></dl></div>

        推特 API -&gt;用 php 更新个人资料 bg 图像

        Twitter API -gt; updating profile bg image with php(推特 API -gt;用 php 更新个人资料 bg 图像)

          <tbody id='Y1p7A'></tbody>

        1. <tfoot id='Y1p7A'></tfoot>
        2. <i id='Y1p7A'><tr id='Y1p7A'><dt id='Y1p7A'><q id='Y1p7A'><span id='Y1p7A'><b id='Y1p7A'><form id='Y1p7A'><ins id='Y1p7A'></ins><ul id='Y1p7A'></ul><sub id='Y1p7A'></sub></form><legend id='Y1p7A'></legend><bdo id='Y1p7A'><pre id='Y1p7A'><center id='Y1p7A'></center></pre></bdo></b><th id='Y1p7A'></th></span></q></dt></tr></i><div id='Y1p7A'><tfoot id='Y1p7A'></tfoot><dl id='Y1p7A'><fieldset id='Y1p7A'></fieldset></dl></div>
          <legend id='Y1p7A'><style id='Y1p7A'><dir id='Y1p7A'><q id='Y1p7A'></q></dir></style></legend>
                • <bdo id='Y1p7A'></bdo><ul id='Y1p7A'></ul>

                  <small id='Y1p7A'></small><noframes id='Y1p7A'>

                  本文介绍了推特 API -&gt;用 php 更新个人资料 bg 图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  到目前为止,我一直在尝试使用 php 通过 twitter api 更新 twitter 个人资料 bg 图像......但没有成功

                  So far I have been trying to update the twitter profile bg image thr the twitter api with php... and without success

                  网上很多例子,包括这个:
                  通过 API 更新 Twitter 背景
                  还有这个
                  Twitter后台上传API和多表单数据
                  根本不起作用,大多数人在没有实际测试代码的情况下抛出答案.

                  Many examples on the web, including this one:
                  Updating Twitter background via API
                  and this one
                  Twitter background upload with API and multi form data
                  do not work at all, most ppl throw out answers without actually testing the code.

                  我发现直接将图片提交到twitter.com thr html表单,它会工作:

                  I found that directly submit the image to the twitter.com thr html form, it will work:

                  <form action="http://twitter.com/account/update_profile_background_image.xml" enctype="multipart/form-data" method="post">
                      File: <input type="file" name="image" /><br/>
                      <input type="submit" value="upload bg">
                  </form>
                  

                  (尽管浏览器会提示您输入 twitter 帐户的用户名和密码)

                  (although the browser will prompt you for the twitter account username and password)

                  但是,如果我想使用 php 进行相同的过程,它会失败

                  However, if I want to go thr the same process with php, it fails

                  <?php
                  if( isset($_POST["submit"]) ) {
                  
                      $target_path = "";
                      $target_path = $target_path . basename( $_FILES['myfile']['name']); 
                  
                      if(move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
                          // "The file ".  basename( $_FILES['myfile']['name']). " has been uploaded<br/>";
                      } else{
                          // "There was an error uploading the file, please try again!<br/>";
                      }
                  
                      $ch = curl_init('http://twitter.com/account/update_profile_background_image.xml');
                      curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
                      curl_setopt($ch, CURLOPT_USERPWD, $_POST['name'] . ':' . $_POST['pass']);
                      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
                      curl_setopt($ch, CURLOPT_TIMEOUT, 1);
                      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                      curl_setopt($ch, CURLOPT_POST, 1);
                      curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => base64_encode(file_get_contents($target_path))));
                  
                      $rsp = curl_exec($ch);
                      echo "<pre>" . str_replace("<", "&lt;", $rsp) . "</pre>";
                  
                  }
                  ?>
                  <form enctype="multipart/form-data" method="post">
                  <input type="hidden" name="submit" value="1"/>
                  name:<input type="text" name="name" value=""/><br/>
                  pass:<input type="password" name="pass" value=""/><br/>
                  File: <input type="file" name="myfile" /><br/>
                  <input type="submit" value="upload bg">
                  </form>
                  

                  这段代码的奇怪之处在于..它成功返回了 twitter XML,没有更新了个人资料背景图像.所以最后还是失败了.

                  The strange thing of this code is that.. it successfully returns the twitter XML, WITHOUT having the profile background image updated. So at the end it still fails.

                  非常感谢您阅读本文.如果您能提供帮助,那就太好了.请在抛出答案之前先测试您的代码,非常感谢.

                  Many thanks for reading this. It will be great if you can help. Please kindly test your code first before throwing out answers, many many thanks.

                  推荐答案

                  这对我有用(调试遗留的东西):

                  This is what works for me (debug stuff left in):

                  $url      = 'http://twitter.com/account/update_profile_background_image.xml';
                  $uname    = 'myuname';
                  $pword    = 'mypword';
                  $img_path = '/path/to/myimage.jpg';
                  $userpwd  = $uname . ':' . $pword;
                  $img_post = array('image' => '@' . $img_path . ';type=image/jpeg',
                                    'tile'  => 'true');
                  
                  $opts = array(CURLOPT_URL => $url,
                                CURLOPT_FOLLOWLOCATION => true,
                                CURLOPT_RETURNTRANSFER => true,
                                CURLOPT_HEADER => true,
                                CURLOPT_POST => true,
                                CURLOPT_POSTFIELDS => $img_post,
                                CURLOPT_HTTPAUTH => CURLAUTH_ANY,
                                CURLOPT_USERPWD => $userpwd,
                                CURLOPT_HTTPHEADER => array('Expect:'),
                                CURLINFO_HEADER_OUT => true);
                  
                  $ch = curl_init();
                  curl_setopt_array($ch, $opts);
                  $response = curl_exec($ch);
                  $err      = curl_error($ch);
                  $info     = curl_getinfo($ch);
                  curl_close($ch);
                  
                  echo '<pre>';
                  echo $err . '<br />';
                  echo '----------------' . '<br />';
                  print_r($info);
                  echo '----------------' . '<br />';
                  echo htmlspecialchars($response) . '<br />';
                  echo '</pre>';
                  

                  这篇关于推特 API -&gt;用 php 更新个人资料 bg 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                      <tbody id='YTfCe'></tbody>
                    <legend id='YTfCe'><style id='YTfCe'><dir id='YTfCe'><q id='YTfCe'></q></dir></style></legend>
                      <tfoot id='YTfCe'></tfoot>

                      <small id='YTfCe'></small><noframes id='YTfCe'>

                        <bdo id='YTfCe'></bdo><ul id='YTfCe'></ul>

                          <i id='YTfCe'><tr id='YTfCe'><dt id='YTfCe'><q id='YTfCe'><span id='YTfCe'><b id='YTfCe'><form id='YTfCe'><ins id='YTfCe'></ins><ul id='YTfCe'></ul><sub id='YTfCe'></sub></form><legend id='YTfCe'></legend><bdo id='YTfCe'><pre id='YTfCe'><center id='YTfCe'></center></pre></bdo></b><th id='YTfCe'></th></span></q></dt></tr></i><div id='YTfCe'><tfoot id='YTfCe'></tfoot><dl id='YTfCe'><fieldset id='YTfCe'></fieldset></dl></div>