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:
我使用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
发布评论