Reply to this topicStart new topic
Problem with PHP SDK, The second argument should be either an array or an object
Armand Brahaj
post Sep 15 2009, 01:10 PM
Post #1
Group: Members
Posts: 4



I am trying to start testing the PHP SDK but I cannot get much out of it. It seems strange error and I wonder if anyone is having the same problems:

I have a simple code in PHP
QUOTE
<?php
// Include the PHP SDK to access library
include_once("yosdk/lib/Yahoo.inc");
// Your Consumer Key (API Key) goes here.
define('CONSUMER_KEY', "myconsumerKEY--");

// Your Consumer Secret goes here.
define('CONSUMER_SECRET', "myconsumerSECRET");

// Your application ID goes here.
define('APPID', "8nWCnY76");

$session = YahooSession::requireSession(CONSUMER_KEY,CONSUMER_SECRET,APPID);
?>



When I call this file in the browser I get:
<br />
<b>Warning</b>: array_key_exists() [<a href='function.array-key-exists'>function.array-key-exists</a>]: The second argument should be either an array or an object in <b>/home/lajme2/public_html/yahoo/yosdk/lib/Yahoo.inc</b> on line <b>1507</b><br />
<br />
<b>Warning</b>: array_key_exists() [<a href='function.array-key-exists'>function.array-key-exists</a>]: The second argument should be either an array or an object in <b>/home/lajme2/public_html/yahoo/yosdk/lib/Yahoo.inc</b> on line <b>1498</b><br />

<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/lajme2/public_html/yahoo/yosdk/lib/Yahoo.inc:1507) in <b>/home/lajme2/public_html/yahoo/yosdk/lib/Yahoo.inc</b> on line <b>341</b><br />


Any suggestions as what might be wrong?
I checked the Line 1507 and it seems a normal call on a return from the function below:
QUOTE
function hasAccessToken() {
1507: return array_key_exists("yosdk_at", $_SESSION) && (strlen($_SESSION["yosdk_at"]) > 0);
}
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Sep 15 2009, 02:21 PM
Post #2
Group: Yahoos
Posts: 942



Try removing the app id from the require_session call (only input the first two arguments for consumer and secret keys)...see if that works. If not, make sure that nothing else is being echoed out to the screen (like spaces) because the header call will fair with that error if that's the case.

Jonathan LeBlanc
Technology Evangelist
Yahoo! Developer Network
Twitter: jcleblanc

This post has been edited by Jonathan LeBlanc: Sep 15 2009, 02:22 PM
Go to the top of the page
 
+Quote Post
Armand Brahaj
post Sep 15 2009, 02:28 PM
Post #3
Group: Members
Posts: 4



QUOTE (Jonathan LeBlanc @ Sep 15 2009, 02:21 PM) *
Try removing the app id from the require_session call (only input the first two arguments for consumer and secret keys)...see if that works. If not, make sure that nothing else is being echoed out to the screen (like spaces) because the header call will fair with that error if that's the case.

Jonathan LeBlanc
Technology Evangelist
Yahoo! Developer Network
Twitter: jcleblanc


Thank you for the reply.
I tried removing and still the same error.
I also tried the code from: http://developer.yahoo.com/yos/code_exs/my...ource_code.html mysocial.php (by adding ofcourse a new API Key (OAuth consumer key)). This time I tried in another server and still the same error (first try on Debian , this time on CentOS).

Can someone confirm that the examples work fine?
Go to the top of the page
 
+Quote Post
Armand Brahaj
post Sep 15 2009, 02:30 PM
Post #4
Group: Members
Posts: 4



QUOTE (Armand B @ Sep 15 2009, 02:28 PM) *
Thank you for the reply.
I tried removing and still the same error.
I also tried the code from: http://developer.yahoo.com/yos/code_exs/my...ource_code.html mysocial.php (by adding ofcourse a new API Key (OAuth consumer key)). This time I tried in another server and still the same error (first try on Debian , this time on CentOS).

Can someone confirm that the examples work fine?

Ah, in the mysocial.php the code is:
$yahoo_session = YahooSession::requireSession(API_KEY, SHARED_SECRET);
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Sep 16 2009, 07:27 AM
Post #5
Group: Yahoos
Posts: 942



That's odd - the code that you are using is the same that I am for one of you apps. Can you try the following please:

1. Remove all content for the app with the exception of the following. Test again and see if that loads:
CODE
<?php
require_once('yosdk/lib/Yahoo.inc');

//define constants to store your API Key (Consumer Key) and Shared Secret (Consumer Secret)
define(CONSUMER_KEY,"KEY HERE");
define(CONSUMER_SECRET,"KEY HERE");

//initializes session and user
$yahoo_session = YahooSession::requireSession(CONSUMER_KEY, CONSUMER_SECRET);
$yahoo_user = $yahoo_session->getSessionedUser();
?>


2. Do you have the most recent version of the PHP SDK? Just to make sure can you get the files directly from: http://github.com/yahoo/yos-social-php

Try those two and see if it loads up.

- Jon

This post has been edited by Jonathan LeBlanc: Sep 16 2009, 07:27 AM
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Sep 16 2009, 09:04 AM
Post #6
Group: Yahoos
Posts: 942



I was just speaking with one of my colleagues who brought up an issue that he gets when using the PHP SDK - one that produces errors like what you are seeing. It appears that in some instances this problem may come from the lack of specifying a session. If those previous two suggestions don't work, try adding the following to the top of the PHP block:

session_start();

That may be the issue.

- Jon
Go to the top of the page
 
+Quote Post
Armand Brahaj
post Sep 16 2009, 11:46 PM
Post #7
Group: Members
Posts: 4



QUOTE (Jonathan LeBlanc @ Sep 16 2009, 09:04 AM) *
I was just speaking with one of my colleagues who brought up an issue that he gets when using the PHP SDK - one that produces errors like what you are seeing. It appears that in some instances this problem may come from the lack of specifying a session. If those previous two suggestions don't work, try adding the following to the top of the PHP block:

session_start();

That may be the issue.

- Jon


Hello Jon,
I confirm that session_start(); was the problem.
Now I can make use of the rest of the files.
Thank you for your support!

rgds,
Armand
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Sep 17 2009, 06:03 AM
Post #8
Group: Yahoos
Posts: 942



Not a problem - thank you for letting me know what it was. Since this is the first time I've heard of this issue I'll try to find some way of integrating it into some FAQs in case anyone runs into the same blocker.

- Jon
Go to the top of the page
 
+Quote Post
Bing
post Oct 4 2009, 02:41 AM
Post #9
Group: Members
Posts: 1



The same issue met, and resolved:)

Thanks so much!
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Oct 4 2009, 07:36 AM
Post #10
Group: Yahoos
Posts: 942



Bing, there was a recent revision to the PHP SDK to fix an OAuth issue. Can you please try downloading the SDK again from http://www.github.com/yahoo and give try again?

That may solve the issue.

- Jon
Go to the top of the page
 
+Quote Post
« Next Oldest · Social Directory API · Next Newest »
 

Reply to this topicStart new topic

 



rss YDN Forum RSS feeds

YDN Content Copyright © 2010 Yahoo! Inc. All rights reserved. Copyright | Privacy Policy

Help us continue to improve the Yahoo! Developer Network - Send Your Suggestions