我有一个1080p视频,我<video>在我的页面上的HTML5 标签中显示.
是否有一种简单的(ish)javascript方法来检测带宽,因此如果用户连接速度太慢而无法流式传输视频,我可以将视频切换为质量较低的版本?与YouTube的"自动"视频尺寸选择器背后的逻辑类似.
我的网站顶部有我的Twitter个人资料,但我想知道是否有办法过滤掉我的@replies,只显示我的状态更新?
谢谢
把头发拉过这一个.
我正在编写一个连接Facebook的网络应用程序,最终会将一些任意信息发布到整个过程中选择的朋友的墙上.
我现在处于最后阶段并希望张贴到墙上会很简单,但我花了很长时间试图解决这个问题,所以我希望有人可以帮助我.
我试图像这样使用ajax发布:
$.ajax({
type: 'POST',
url: "https://graph.facebook.com/bbeckford/feed",
data: {message: wallMessage, target_id: friendID, access_token: "<?= $cookie['access_token'] ?>", format: "json"},
success: function(data) { alert(data); },
dataType: "JSON"
});
Run Code Online (Sandbox Code Playgroud)
但我只是不断收到这个错误:"XMLHttpRequest无法加载https://graph.facebook.com/bbeckford/feed.来自Access-Control-Allow-Origin不允许来源http://www.secretsantasetup.com."
我已经完成了搜索,一个建议是制作一个php代理,这是一个可行的选择吗?我该怎么做呢?
我接近这个完全错了吗?
任何帮助将不胜感激,谢谢,-Ben
编辑 我想在后台执行此操作,例如用户选择了10个朋友,然后提交应用程序将循环通过每个朋友并在他们的墙上发布一些东西.这可能吗?谢谢!
编辑2 下一页底部的测试控制台完全符合我的要求,但没有源代码?- http://developers.facebook.com/docs/reference/rest/stream.publish
我有一个数组设置如下:
$myArray = array();
$myArray[] = "New array item 1";
$myArray[] = "New array item 2";
$myArray[] = "New array item 3";
Run Code Online (Sandbox Code Playgroud)
当我在其上运行json_encode()时,它会输出以下内容:
["New array item 1","New array item 2","New array item 3"]
Run Code Online (Sandbox Code Playgroud)
我想要的是函数将索引编码为字符串:
{"0":"New array item 1","1":"New array item 2","2":"New array item 3"}
Run Code Online (Sandbox Code Playgroud)
所以以后我可以删除说第一项而不影响第二项的索引.
是否有捷径可寻?
我整个上午一直在寻找这个.
是否有一个简单的PHP函数将复制我的服务器上的文件夹,如果需要,会暂时更改权限?基本上是PHP替代我使用FTP复制整个文件夹然后再次备份?
我已经尝试了下面我在网上找到的功能,但我觉得它可能没什么可能是由于权限.我已经尝试过error_reporting(E_ALL);并且还检查了每个的返回值copy(),它们都返回false.
copy_directory('/directory1','/directory2')
function copy_directory($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
copy_directory($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
Run Code Online (Sandbox Code Playgroud) 我一直在努力使用jQuery.get()来引入我的动态生成的RSS提要,而我只有问题,我的RSS源是错误的格式吗?如果是这样我可以使用javascript将其转换为正确的格式?
这是我的饲料:http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id = 0
这是我的代码:
function get_rss_feed() {
$(".content").empty();
$.get("http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0", function(d) {
var i = 0;
$(d).find('item').each(function() {
var $item = $(this);
var title = $item.find('title').text();
var link = $item.find('link').text();
var location = $item.find('location').text();
var pubDate = $item.find('pubDate').text();
var html = '<div class="entry"><a href="' + link + '" target="_blank">' + title + '</a></div>';
$('.content').append(html);
i++;
});
});
};
Run Code Online (Sandbox Code Playgroud)
任何投入将不胜感激!!谢谢
所以我使用javascript将一个JSON字符串中的对象数组发布到PHP脚本中,并且我在php中解码它时遇到了实际问题.
我的javascript如下:
$.ajax({
type: 'POST',
url: "question_save.php",
data: {myJson: JSON.stringify(jsonArray)},
success: function(data){
alert(data);
}
});
Run Code Online (Sandbox Code Playgroud)
发送给PHP的字符串如下所示:
[{"content":"Question text"},{"answerContent":"Some answer text","score":"234","responseChecked":0,"responseContent":""},{"answerContent":"","score":"0","responseChecked":0,"responseContent":""}]
Run Code Online (Sandbox Code Playgroud)
如果我回复$ _POST ['myJson']我得到这个:
[{\"content\":\"Question text\"},{\"answerContent\":\"Some answer text\",\"score\":\"234\",\"responseChecked\":0,\"responseContent\":\"\"},{\"answerContent\":\"\",\"score\":\"0\",\"responseChecked\":0,\"responseContent\":\"\"}]
Run Code Online (Sandbox Code Playgroud)
然而,当我想解码JSON并像这样循环它...
$json = $_POST['myJson'];
$data = json_decode($json, true);
foreach ($data as &$value) {
echo("Hi there");
}
Run Code Online (Sandbox Code Playgroud)
...我收到此错误:
Warning: Invalid argument supplied for foreach() in /home/thecrime/public_html/test1/question_save.php on line 15
Run Code Online (Sandbox Code Playgroud)
我真的不明白我正在制造什么愚蠢的错误,是否与反斜杠有关?
任何帮助非常感谢!
谢谢,-Ben
我开始使用WideImage图像处理库,我对它生成的JPEG图像的质量有疑问.WideImage实际上使用GD,所以我只是使用GD PHP图像功能进行测试.
我的目标是最终调整图像大小,但这是我的测试代码,没有调整大小:
$srcImage = "path/to/image.jpg";
list($width, $height) = getimagesize($srcImage);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($srcImage);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
imagejpg($image_p, "path/to/image_resized.jpg", 100);
Run Code Online (Sandbox Code Playgroud)
这可行,但输出质量较低的原始图像的更多褪色版本.以下是原始拆分中心旁边的示例:

当我执行调整大小时也会发生这种情况,但我希望保持原始图像的相同颜色/质量.
有没有人有任何关于如何实现这一点的想法?我的php.ini中可能有一个设置,我缺少什么?我也尝试使用imagepng(),但结果大致相同.
我正在使用PHP版本5.3.29,这是来自phpinfo()的我的GD信息:
GD Support : enabled
GD Version : bundled (2.1.0 compatible)
FreeType Support : enabled
FreeType Linkage : with freetype
FreeType Version : 2.3.11
T1Lib Support : enabled
GIF Read Support : enabled
GIF Create Support: enabled
JPEG Support : enabled …Run Code Online (Sandbox Code Playgroud) 当我尝试运行此语句时:
CREATE TABLE 'score_table'
(
'name' text NOT NULL,
'email' text NOT NULL,
'company' text NOT NULL,
'score_total' bigint(11) NOT NULL,
'score_string' longtext NOT NULL,
'id' int(11) NOT NULL auto_increment,
'date' timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY ('id')
)
ENGINE=MYISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
#1064 - You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near ''score_table'
('name' text NOT …Run Code Online (Sandbox Code Playgroud)