Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表格won';t柱_Php_Html_Post_Twitter_Twitter Oauth - Fatal编程技术网

Php 表格won';t柱

Php 表格won';t柱,php,html,post,twitter,twitter-oauth,Php,Html,Post,Twitter,Twitter Oauth,我正在尝试使用PHP/POST/etc来帮助我做一名Webdev。从教程等,我在网上看到,这应该是可行的。但是,当我单击submit时,页面被重定向到bagelBack.php,但是有一个空白页面,推文没有提交。我在自己的机器上,使用XAMPP Apache。(如果有帮助的话,HTML页面上有jQuery) 编辑:它在php的第40行失败($connection->request,等等)var_dumps工作,但echo不工作。我对这一切都不熟悉。为什么这不是一个错误 Html: Twitte

我正在尝试使用PHP/POST/etc来帮助我做一名Webdev。从教程等,我在网上看到,这应该是可行的。但是,当我单击submit时,页面被重定向到
bagelBack.php
,但是有一个空白页面,推文没有提交。我在自己的机器上,使用XAMPP Apache。(如果有帮助的话,HTML页面上有jQuery)

编辑:它在php的第40行失败(
$connection->request
,等等)
var_dump
s工作,但
echo
不工作。我对这一切都不熟悉。为什么这不是一个错误

Html:


Twitter名称:
面包圈类型:
PHP(主要来自):


我不久前写这篇文章时遇到了同样的问题:


这与网络主机安装的fcgi与cgi-SAPI有关。

您是否尝试使用var_dump($name)变量来查看是否存在任何问题?你是否也尝试过删除post_tweet功能,看看是否可以让帖子转到下一页?文件名是否正确?您是否尝试过
echo$name
echo$类型?你看到了什么?变量很好。问题出在
post_tweet
为什么它会那样死掉而不显示错误?你可能有错误没有显示或其他什么。您的tmhOAuth.php是否与bagelBack.php位于同一位置?php错误报告设置为E_ALL&~E_STRICT。是的,它在同一个目录中。我在我的PHP上发布的很好。问题在于post_tweet功能。
<form id="bagelForm" action="bagelBack.php" method="POST">
    <label for="twitterName">Twitter Name: </label><input type="text" id="twitterName" name="twitterName"/><br />
    <label for="bagelType">Bagel Type: </label><input type="text" id="bagelType" name="bagelType"/><br />
    <input type="submit" />
</form>
<?php
/**
* bagelBack.php
* Example of posting a tweet with OAuth
* Latest copy of this code: 
* http://140dev.com/twitter-api-programming-tutorials/hello-twitter-oauth-php/
* @author Adam Green <140dev@gmail.com>
* @license GNU Public License
*/

$name = "@".$_POST['twitterName'];
$type = $_POST['bagelType'];

$tweet_text = $name.", your ".$type." bagel has finished toasting!";
$result = post_tweet($tweet_text);
echo "Response code: " . $result . "\n";

function post_tweet($tweet_text) {

  // Use Matt Harris' OAuth library to make the connection
  // This lives at: https://github.com/themattharris/tmhOAuth
  require_once('tmhOAuth.php');

  // Set the authorization values
  // In keeping with the OAuth tradition of maximum confusion, 
  // the names of some of these values are different from the Twitter Dev interface
  // user_token is called Access Token on the Dev site
  // user_secret is called Access Token Secret on the Dev site
  // The values here have asterisks to hide the true contents 
  // You need to use the actual values from Twitter
  $connection = new tmhOAuth(array(
    'consumer_key' => '[redacted]',
    'consumer_secret' => '[redacted]',
    'user_token' => '[redacted]',
    'user_secret' => '[redacted]'
  )); 

  // Make the API call
  $connection->request('POST', 
    $connection->url('1/statuses/update'), 
    array('status' => $tweet_text));

  return $connection->response['code'];
}
?>