我试图将照片发布到我的应用程序Facebook粉丝页面和用户墙上.我已经成功将照片发布在用户墙上,但未能将其发布在粉丝页面墙上.(用户不一定是管理员或页面所有者,只是常规用户.由于粉丝页面可以选择任何人发帖,因此用户甚至不必首先喜欢该页面.对吧?)
谷歌搜索了一段时间后,我找到了这个答案.根据它,我需要粉丝页面的access_token和album_id这样做.但我找不到任何关于如何获得它们的线索.到目前为止,我尝试过这段代码:
if ([appDelegate.facebook isSessionValid])
{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
resultImage, @"picture",
nil];
[appDelegate.facebook requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self]; // to post on users wall, works fine
NSString *path = [NSString stringWithFormat:@"my/accounts /fan_page_id?fields=access_toke/photos"];
[appDelegate.facebook setAccessToken: FACEBOOK_ACCESS_TOKEN];
[appDelegate.facebook requestWithGraphPath:path andParams:params andHttpMethod:@"POST" andDelegate:self]; // to post on fan page wall, this doesn't work
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我这个?我在这里错过了什么?提前致谢.
UPDATE
根据这个答案,普通用户无法从iOS应用程序将照片发布到粉丝页面墙,但可以在其上共享照片.现在,我的问题是,如何在用户墙上发布照片并同时在粉丝页面墙上分享?可能吗?如何在粉丝页面墙上分享照片?
更新2
这个答案和问题说普通用户可以通过新闻提要发布到粉丝页面墙,所以我修改了我的代码:
if ([appDelegate.facebook isSessionValid]) {
NSMutableDictionary *page_params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"fan_page_id", @"to",
@"Test", @"name",
@"Test", @"caption",
resultImage, …Run Code Online (Sandbox Code Playgroud) 我是codeigniter的新手.我使用登录表单作为管理员登录.当管理员使用正确的用户名和密码登录时,他/她被引导到带有会话变量的主页.然后,如果他点击退出按钮,会话应该被销毁并将用户重定向到登录页面即登录表单页面.
第一个控制器是管理员:
<?php
class Admin extends CI_Controller
{
function index()
{
$data['main_content'] = 'admin/log_in';
$this -> load -> view('includes/admin/admin_template', $data);
}
function log_in()
{
$this->load->model('admin_model');
$query = $this -> admin_model -> validate();
if ($query)// if the user's credentials validated...
{
$data = array('user_name' => $this -> input -> post('user_name'), 'is_logged_in' => true);
$this -> session -> set_userdata($data);
redirect('admin/home/admin_home');
} else// incorrect username or password
{
$this -> index();
}
}
function log_out()
{
$this->session->sess_destroy();
redirect('/admin/admin','refresh');
}
}
Run Code Online (Sandbox Code Playgroud)
第二个控制器是家庭控制器:
<?php
class …Run Code Online (Sandbox Code Playgroud) 我正在使用CodeIgniter 2.1.0和MySQL数据库.我已经通过表单上传了一张图片并成功将其存储在uploads目录中,并且我还成功地将图像的完整路径存储在我的数据库中.但我通过从我的数据库调用完整路径显示图像有问题.
这是我上传的代码:
$image_path = realpath(APPPATH . '../uploads');
$config = array(
'allowed_types' => 'jpeg|png|gif|jpg',
'upload_path' => $image_path,
'max_size' => 2097152,
'overwrite' => TRUE,
'file_name' => '_' . $i . '_'
);
$this -> load -> library('upload', $config);
Run Code Online (Sandbox Code Playgroud)
当我在图像数据库中存储图像的完整路径时,它看起来像这样
C:/wamp/www/my_project/uploads/_1_.jpg
Run Code Online (Sandbox Code Playgroud)
如果我试试
<img src="<?php echo $data['screenshot'];?>" />
//($data['screenshot'] refers to the image location retrieved from database)
Run Code Online (Sandbox Code Playgroud)
这在我的视图文件中,没有显示图像.我究竟做错了什么?请有人告诉我.什么是标准程序?
mysql image-processing image-uploading imageview codeigniter-2
我正在使用 UIPanGestureRecognizer 来识别对象的拖动移动,它适用于以下状态:
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
[panGesture setMaximumNumberOfTouches:1];
[panGesture setDelegate:self];
[self.view addGestureRecognizer:panGesture];
[panGesture release];
- (void)panAction:(UIPanGestureRecognizer *)gR
{
switch (gR.state)
{
case UIGestureRecognizerStateBegan:
NSLog(@"drag began");
break;
case UIGestureRecognizerStateChanged:
NSLog(@"drag moved");
break;
case UIGestureRecognizerStateEnded:
NSLog(@"drag ended");
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,是否可以检测用户开始拖动对象并在某个时刻停止拖动并将对象保持在固定点的情况?我已经检查过,当用户停止移动对象时,它会停止记录“更改”,直到用户开始移动对象或释放它(在这种情况下,它会记录“结束”)。这是一个示例日志:
2013-02-19 16:36:**01.181** Project[24201:10a03] drag began
2013-02-19 16:36:**14.004** Project[24201:10a03] drag moved
2013-02-19 16:36:14.221 Project[24201:10a03] drag moved
2013-02-19 16:36:**14.894** Project[24201:10a03] drag ended
Run Code Online (Sandbox Code Playgroud)
您可以看到开始、更改和结束之间有一些暂停(此时对象固定在某个点)。是否可以检测到这种情况?如果是这样,怎么办?任何帮助将不胜感激,提前致谢。
更新
我尝试过 UILongPressGestureRecognizer:
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
[longPressGesture setDelegate:self];
[self.view addGestureRecognizer:longPressGesture]; …Run Code Online (Sandbox Code Playgroud) 我正在使用codeigniter 2.1.0和mysql数据库.在我的管理面板中,我有一个页面,我想向所有用户显示分页视图.但它不起作用.在
这里尝试了很多东西之后是我更新的代码
控制器:
function accounts() // controller to view all users
{
$this -> load -> library('pagination');
$config['base_url'] = site_url('admin/home/accounts/');
$config['total_rows'] = $this->db->get('user')->num_rows();
$config['per_page'] = 2;
$config['num_links'] = 2;
$config['full_tag_open'] = '<p id="pagination">';
$config['full_tag_close'] = '</p>';
$offset = $this->uri->segment(4,0);
$this->pagination->initialize($config);
$this->load->model('admin_model');
$data['user_data']=$this->admin_model->all_user($config['per_page'],$offset);
$data['links']=$this -> pagination -> create_links();
$data['main_content']='admin/accounts';
$this->load->view('includes/admin/admin_template',$data);
}
Run Code Online (Sandbox Code Playgroud)
视图:
<?php foreach ($user_data as $data) {?>
<?php echo 'Name:' . ' ' ?>
<?php echo ($data['name']).'<br/>'; ?>
<?php echo 'E-mail:' . ' ' ?>
<?php echo …Run Code Online (Sandbox Code Playgroud) 如果三个布尔值中至少有两个是真的,这是最容易找到的方法:
BOOL a, b, c;
-(BOOL)checkAtLeastTwo
{
return a && (b || c) || (b && c);
}
Run Code Online (Sandbox Code Playgroud)
如果有10个布尔并且其中至少有两个需要是真的,那么最佳解决方案是什么?提前致谢.
我正在尝试重命名图像文件并将文件位置保存在数据库中。我遇到了问题,因为我想将文件命名为我要插入的表行的 id。上传并插入后,我想看到我的表,如下所示:
----------------------------------------
| id | name | category | image |
----------------------------------------
| 1 | foo | category | uploads/1.jpg |
----------------------------------------
Run Code Online (Sandbox Code Playgroud)
id 字段自动递增。这是我的代码:
function service()
{
$con=$this->do_upload();
$id=mysql_insert_id();
$data=array(
'name'=>$this->input->post('name'),
'category'=>$this->input->post('category'),
'image'=>'uploads/'.$id.$con['file_ext'];
);
$query=$this->db->insert('table',$data);
return $query;
}
Run Code Online (Sandbox Code Playgroud)
这不是正确的方法,并且假设文件没有按需要保存在数据库中。而不是将其保存为“uploads/1.jpg”,而是将其保存为“uploads/0.jpg”。
任何人都可以为我提供正确的约定来做到这一点吗?注意我正在使用codeigniter 2.1.0和mySQL数据库。