Codeigniter:从视图页面重定向到另一个URL

编程入门 行业动态 更新时间:2024-10-17 20:22:55
本文介绍了Codeigniter:从视图页面重定向到另一个URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

google-php-client示例在用户点击链接时调用授权网址。我想在页面加载时调用它,而无需任何用户点击。 在google-client示例中实现的方式:

google-php-client example calls the authorization URL when user clicks a link. I want to call it when page loads without any user click. The way it is implemented in google-client example:

$client = new Google_Client(); $client->setApplicationName('Google Contacts PHP Sample'); $client->setScopes("www.google/m8/feeds/"); $auth = $client->createAuthUrl(); print "<a class=login href='$auth'>Connect Me!</a>";

我试图删除依赖关系点击 Connect Me 由 $ client-> createAuthUrl()给出的链接和调用网址。我是Codeigniter的新人,这就是为什么在这个简单的任务上奋斗。我我检查有以下不同的方式来调用URL,但不知道哪一个将在这里工作:

I am trying to remove dependency on clicking on Connect Me link and call url given by $client->createAuthUrl(). I am new to Codeigniter that's why struggling on this simple task. I check that there are following different ways to call an URL but not sure which one will work here:

  • cURL
  • file_get_contents
  • stream_context_create
  • 我使用php 5.3与XAMPP

    I am using php 5.3 with XAMPP

    推荐答案

    对于一个简单的重定向使用CodeIgniter的库,请使用以下命令:

    For a simple redirect using CodeIgniter's libraries, use the following:

    $client = new Google_Client(); $client->setApplicationName('Google Contacts PHP Sample'); $client->setScopes("www.google/m8/feeds/"); $auth = $client->createAuthUrl(); $this->load->helper('url'); redirect($auth); // Returns a HTTP redirect to the client

    这是一个包装器 ('location')传递第二个参数时,

    This is a wrapper around header('Location: ... '); when no second parameter is passed (or is passed as 'location').

    更多推荐

    Codeigniter:从视图页面重定向到另一个URL

    本文发布于:2023-11-01 01:50:32,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1547896.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:视图   重定向   页面   Codeigniter   URL

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!