我的小Facebook应用程序遇到了一些麻烦,我不断得到这个friggin错误,"致命的错误:调用未定义的方法Facebook :: require_login()",现在有趣的是,我的完全相同的代码正在为其他人工作,但不适合我,这是代码.
<?php
require_once( "facebook-php-sdk/src/facebook.php" );
$api_key = "my_api_key";
$secret = "my_secret_key";
$facebook = new Facebook( $api_key, $secret );
$user_id = $facebook->require_login();
echo "Hello World";
echo "Current logged in as <fb:name uid=\"$user_id\" />";
?>
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样,它是一个简单的hello USER应用程序,但由于某些原因,这个REFUSES可以为我工作,所以如果有人可以提供帮助,那将是伟大的,而不是提前!
我使用D3创建了一个小测试线图,但由于我对库很新,我不确定在图表中添加多行是最好的方法,目前我只有一行显示小提琴.
我想在图表上显示2行,但我不确定如何在没有复制粘贴代码的情况下实现这一点,我相信这将是非常低效的,因为我想根据用户选择定期更新/动画图形.
而不是这个,
var data = [12345,22345,32345,42345,52345,62345,72345,82345,92345,102345,112345,122345,132345,142345];
Run Code Online (Sandbox Code Playgroud)
我想展示这样的东西,
var data = [
[12345,42345,3234,22345,72345,62345,32345,92345,52345,22345], // line one
[1234,4234,3234,2234,7234,6234,3234,9234,5234,2234] // line two
];
Run Code Online (Sandbox Code Playgroud)
这可能吗?如果是这样,那么最好的方法是什么,以便我可以在需要时轻松更新/动画图形?
注意:我只是想学习并熟悉D3最佳实践和整个库.谢谢.
我已经获得了照片上传功能来使用此代码,
<?php
include_once 'facebook-php-sdk/src/facebook.php';
include_once 'config.php';//this file contains the secret key and app id etc...
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET_KEY,
'cookie' => true,
'domain' => 'your callback url goes here'
));
$session = $facebook->getSession();
if (!$session) {
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'req_perms'=>'user_photos,publish_stream,offline_access'//here I am requesting the required permissions, it should work with publish_stream alone, but I added the others just to be safe
));
echo 'You are not logged in, …
Run Code Online (Sandbox Code Playgroud) 我试图将图像上传到Facebook粉丝页面上的图库,这是我的代码到目前为止,
$ch = curl_init();
$data = array('type' => 'client_cred', 'client_id' => 'app_id','client_secret'=>'secret_key',' redirect_uri'=>'http://apps.facebook.com/my-application/'); // your connect url here
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/oauth/access_token');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$rs = curl_exec($ch);
curl_close($ch);
$ch = curl_init();
$data = explode("=",$rs);
$token = $data[1];
$album_id = '1234';
$file= 'http://my.website.com/my-application/sketch.jpg';
$data = array(basename($file) => "@".realpath($file),
//filename, where $row['file_location'] is a file hosted on my server
"caption" => "test",
"aid" => $album_id, //valid aid, as demonstrated above
"access_token" => $token
);
$ch2 = …
Run Code Online (Sandbox Code Playgroud) 我试图克隆一个元素,然后遍历它的子元素并相应地更改属性,事情是我试图通过使用CSS选择器的自定义属性访问元素,我似乎无法让它工作,这里就是我到目前为止,
HTML:
<div id='main_container'>
<div id="container">
<div class="wrapper">
<div><label>... </label></div>
<div><input type="text" id="one" new="one_1" /></div>
</div>
<div class="wrapper">
<div><label>... </label></div>
<div>
<select id="two" new="two_1" >
<option>...</option>
<option>...</option>
</select>
</div>
</div>
<div class="wrapper">
<div><label>... </label></div>
<div>
<select id="three" new="three_1" >
<option>...</option>
<option>...</option>
</select>
</div>
</div>
</div>
<div class="wrapper">
<input type="button" value="add a section" id="button" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$('#button').click(function(){
var clone = $('#container').clone().appendTo('#main_container');
clone.children('["new*=one"]').attr('class', 'one');
clone.children('["new*=two"]').attr('class', 'two');
clone.children('["new*=three"]').attr('class', 'three');
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取一个图像来填充视口并在浏览器调整大小时自动调整大小,这是有效的,唯一的问题是由于某种原因我不能让图像不延伸到#wrapper
元素之外,即使它有溢出设置隐藏,我假设它是因为我使用百分比而不是固定的宽度和高度?
现在,当我放置overflow: hidden;
body元素时,它可以工作,但是当你在页面的任何地方选择文本并向下拖动时,它向下滚动到图像的底部,这是有问题的,因为我有一个绝对定位到页面的页脚菜单屏幕的底部,随着图像被拖下来向上移动,并破坏整个效果.
所以基本上我只想要一个自动调整大小的背景,它不会溢出视口并导致滚动条,这样可以让定位的内容保持原样,而不是在向下拖动选定的文本时向上滚动.
HTML:
<html>
<head>
<title>project</title>
</head>
<body>
<div id="wrapper">
<div id="content">
<img src="image.jpg" width="1400" height="1200" />
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CSS:
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#wrapper {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
}
#content {
width: 100%;
height: 100%;
}
#wrapper img {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud) 正如标题所说,我无法开始.attr('checked', false)
使用IE6.我正在克隆一些HTML,然后在将新克隆的HTML分配给一个元素之前,我运行它并取消检查新克隆部分中的所有复选框,这在除IE 6之外的所有浏览器中都能正常工作.
这是代码:
//give each input and select a custom id
clone.find('input, select').each( function( i ) {
//get the id attribute
var id = $(this).attr('id');
//uncheck all of the tick boxes
$(this).attr('checked', '');
//get the name attribute
var name = $(this).attr('name');
$(this).attr('name', name+"_"+count)
$(this).attr('id', id+"_"+count+"_"+i)
});
//append the newly created area to the area wrapper
clone.appendTo('[data-custom="area_wrapper"]');
Run Code Online (Sandbox Code Playgroud)
有什么方法可以解决这个问题吗?
正如标题所述,我正在尝试迭代一系列子元素,当我尝试逐个淡出它们时会遇到麻烦,我正在$.each()
尝试实现这一点,但它似乎正在逐渐消失我想要做的就是等待动画完成,然后转到下一个子元素并将其淡出,这是我的代码,
jQuery的:
var children = $("container").children();
children.each(function(){
$(this).fadeOut('slow');
})
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="container">
<div style="background: #F00;"></div>
<div style="background: #00F;"></div>
<div style="background: #0F0;"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
是否可以在当前动画完成之前触发动画,但是可以按设定的间隔延迟动画?
提前致谢!
就像标题所说,我正在尝试使用jQuery,JSON和AJAX创建一个下拉菜单,虽然我熟悉我尚未将其付诸实践的理论,任何建议,演示代码片段或教程都将受到赞赏,因为我想开始最好的开始!
Thanx提前!
我正在尝试使用PHP解析JSON字符串,使用$.ajax
此格式的jQuery将JSON发送到PHP文件[{"value":"59"},{"value":"7"},{"value":"46"}]
,但由于一些奇怪的原因我不断收到此错误"Invalid argument supplied for foreach()"
,这是我的PHP和jQuery代码,
jQuery的:
$(".systems").each( function(i, system) {
// for each location block
system = $(system);
var sys = {
'value' : $("select[data-prod='products']", system).val()
};
allSystems.push( sys );
});
$.ajax({
type: 'POST',
url: 'systems.php',
dataType: 'json',
data: { systems: JSON.stringify(allSystems), uid: uid },
success: function(data){
alert(data)
}
});
Run Code Online (Sandbox Code Playgroud)
PHP:
require_once 'classes/Zend/Json.php';
$json = $_POST['systems'];
$uid = $_POST['uid'];
$array= Zend_Json::decode("$json");
mysql_connect('localhost','user','pass') or die(mysql_error());
mysql_select_db('products') or die(mysql_error());
//insert the suppliers products into the database …
Run Code Online (Sandbox Code Playgroud)