PHP cannot find file for require_once, but it's there? - php

It's an error in MyBB, after install I get this error from the index:
Warning: require_once(./global.php): failed to open stream: No such file or directory in C:\jws\htdocs\index.php on line 18
Fatal error: require_once(): Failed opening required './global.php' (include_path='.;C:\php\pear') in C:\jws\htdocs\index.php on line 18
Index code near top:
require_once './global.php';
require_once MYBB_ROOT.'inc/functions_forumlist.php';
require_once MYBB_ROOT.'inc/class_parser.php';
The file is there, I checked in the folder. I haven't changed anything in the files. I'm using PHP 5.6.4, and the index file is loaded from a require_once in another file.
Here:
<?php
$_SERVER = array(
"SERVER_PROTOCOL" => "HTTP/1.1","DOCUMENT_ROOT" => "C:/jws/htdocs","REMOTE_ADDR" => "127.0.0.1","REQUEST_URI" => "/","SERVER_SOFTWARE" => "JWS/1.0","argv" => "","REQUEST_TIME" => "Tue, 30 Dec 2014 12:33:14 PST","PHP_SELF" => "/","REMOTE_PORT" => "56601","REQUEST_METHOD" => "GET","SCRIPT_NAME" => "","SERVER_NAME" => "JWS/1.0","PATH_INFO" => "","ORIG_PATH_INFO" => "","argc" => "","GATEWAY_INTERFACE" => "N/I","SERVER_PORT" => "80","SCRIPT_FILENAME" => "C:/jws/htdocs/index.php","HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.5","HTTP_HOST" => "127.0.0.1","QUERY_STRING" => "","REQUEST_TIME_FLOAT" => "1419971594194","HTTP_ACCEPT" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","HTTP_USER_AGENT" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0","HTTP_ACCEPT_ENCODING" => "gzip, deflate","SERVER_ADDR" => "127.0.0.1","HTTP_CONNECTION" => "keep-alive",
);
$_GET = array(
);
$_POST = array(
);
$_COOKIE = array(
);
$_REQUEST = array(
);
require_once 'C:/jws/htdocs/index.php';
?>

replace your index code with this
require_once 'global.php';
require_once MYBB_ROOT.'inc/functions_forumlist.php';
require_once MYBB_ROOT.'inc/class_parser.php';

I managed to use:
chdir("the path");
to change the working directory, and I also had issues with redirection failure in the server.
Thanks for the help!

index.php code near top:
<?PHP
require_once MYBB_ROOT.'/global.php';
require_once MYBB_ROOT.'/inc/functions_forumlist.php';
require_once MYBB_ROOT.'/inc/class_parser.php';
?>
indexTest.php
<?php
define("MYBB_ROOT", __DIR__);
$_SERVER = array(
"SERVER_PROTOCOL" => "HTTP/1.1","DOCUMENT_ROOT" => "C:/jws/htdocs","REMOTE_ADDR" => "127.0.0.1","REQUEST_URI" => "/","SERVER_SOFTWARE" => "JWS/1.0","argv" => "","REQUEST_TIME" => "Tue, 30 Dec 2014 12:33:14 PST","PHP_SELF" => "/","REMOTE_PORT" => "56601","REQUEST_METHOD" => "GET","SCRIPT_NAME" => "","SERVER_NAME" => "JWS/1.0","PATH_INFO" => "","ORIG_PATH_INFO" => "","argc" => "","GATEWAY_INTERFACE" => "N/I","SERVER_PORT" => "80","SCRIPT_FILENAME" => "C:/jws/htdocs/index.php","HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.5","HTTP_HOST" => "127.0.0.1","QUERY_STRING" => "","REQUEST_TIME_FLOAT" => "1419971594194","HTTP_ACCEPT" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","HTTP_USER_AGENT" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0","HTTP_ACCEPT_ENCODING" => "gzip, deflate","SERVER_ADDR" => "127.0.0.1","HTTP_CONNECTION" => "keep-alive",
);
$_GET = array(
);
$_POST = array(
);
$_COOKIE = array(
);
$_REQUEST = array(
);
require_once MYBB_ROOT.'/index.php';
?>

Related

Yii2 redirecting isn't working. Why?

I am newbie in Yii2, and now I build new app manually (using Mark Safronov book).
I tried to redirect my controller to somewhere and it isn't working.
Like this:
return $this->redirect(array('/site/dashboard'));
I think it depends on my settings, do you have any ideas? I'm using niceurls and this is my httaccess file:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
It is my View code
And I had next config: common/config/bootstrap.php
Yii::setAlias('yii2_book', dirname(dirname(__DIR__)) . '/yii2_book');
Code in my controller:
public function actionAdd()
{
$customer = new CustomerRecord();
$phone = new PhoneRecord();
if($customer->load(Yii::$app->request->post()) && $customer->validate() && $phone->load(Yii::$app->request->post())){
$this->store($this->makeCustomer($customer, $phone));
return $this->redirect(['index']);
}
return $this->render('add',compact('customer','phone'));
Stack trace:
2018-01-05 11:30:03 [::1][-][-][error][yii\web\HttpException:400] yii\web\BadRequestHttpException: Unable to verify your data submission. in /Users/sergejandrejkin/PhpstormProjects/yii2_book/vendor/yiisoft/yii2/web/Controller.php:166
Stack trace:
#0 /Users/sergejandrejkin/PhpstormProjects/yii2_book/vendor/yiisoft/yii2/base/Controller.php(155): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))
#1 /Users/sergejandrejkin/PhpstormProjects/yii2_book/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('add', Array)
#2 /Users/sergejandrejkin/PhpstormProjects/yii2_book/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('customers/add', Array)
#3 /Users/sergejandrejkin/PhpstormProjects/yii2_book/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#4 /Users/sergejandrejkin/PhpstormProjects/yii2_book/web/index.php(12): yii\base\Application->run()
#5 {main}
2018-01-05 11:30:03 [::1][-][-][info][application] $_POST = [
'_csrf' => 'oUDxUGHONyj8ER3vQc9cvdpMsCJh6DXlPzsnxRCxfu3AArIlA7lYR8tnbN8UuDf_937iFlKnc6tGVhCNQvQKiA=='
'CustomerRecord' => [
'name' => ''
'birth_date' => ''
'notes' => ''
]
'PhoneRecord' => [
'number' => ''
]
]
$_SERVER = [
'REDIRECT_STATUS' => '200'
'HTTP_HOST' => 'localhost:8888'
'HTTP_CONNECTION' => 'keep-alive'
'CONTENT_LENGTH' => '208'
'HTTP_CACHE_CONTROL' => 'max-age=0'
'HTTP_ORIGIN' => 'http://localhost:8888'
'HTTP_UPGRADE_INSECURE_REQUESTS' => '1'
'CONTENT_TYPE' => 'application/x-www-form-urlencoded'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
'HTTP_REFERER' => 'http://localhost:8888/web/customers/add'
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, br'
'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7'
'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin'
'SERVER_SIGNATURE' => ''
'SERVER_SOFTWARE' => 'Apache/2.2.31 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.0.15 mod_ssl/2.2.31 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0'
'SERVER_NAME' => 'localhost'
'SERVER_ADDR' => '::1'
'SERVER_PORT' => '8888'
'REMOTE_ADDR' => '::1'
'DOCUMENT_ROOT' => '/Users/sergejandrejkin/PhpstormProjects/yii2_book'
'SERVER_ADMIN' => 'you#example.com'
'SCRIPT_FILENAME' => '/Users/sergejandrejkin/PhpstormProjects/yii2_book/web/index.php'
'REMOTE_PORT' => '49253'
'REDIRECT_URL' => '/web/customers/add'
'GATEWAY_INTERFACE' => 'CGI/1.1'
'SERVER_PROTOCOL' => 'HTTP/1.1'
'REQUEST_METHOD' => 'POST'
'QUERY_STRING' => ''
'REQUEST_URI' => '/web/customers/add'
'SCRIPT_NAME' => '/web/index.php'
'PHP_SELF' => '/web/index.php'
'REQUEST_TIME_FLOAT' => 1515148203.45
'REQUEST_TIME' => 1515148203
'argv' => []
'argc' => 0
]
I've had same issue. Considering store(…) method works fine, try to add Yii::$app->end() after redirect. So
return $this->redirect(['index']);
becomes
$this->redirect(['index']);
Yii::$app->end();
The exception says:
yii\web\BadRequestHttpException: Unable to verify your data submission.
This tell you 2 things:
bad request exception (http code 400): Is a server response that is sent when the request done by the browser is invalid. Checking the exception's stacktrace you can see its thrown in the beforeAction of the actionAdd so your redirect isnt the problem, as the exception is before your code.
Yii usually use this exception when the CSRF check is invalid, so you should check this page
check it out , do you have any echo before that ?
if have just clear it by ob_end_clean();
if any echo or header have exist before redirect , it's wont be work !
try :
flush();
or try
ob_start()
if no one works try javascript method :
echo "<script type='text/javascript'> window.location='http://your complete url .. '; </script>";
that will works 100% ,good luck .
Yes please check your config settings.
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
],
]
Also your mod_rewrite module should be enabled.
Hope it helps!

undefined variable on CI controller

I have some issue on $PYParentID for the following code. I'll always get and undefined variable error that showes up when I execute my post action. Am I missing something?
Error message
Undefined variable: PYParentID loc: C:\xampp\htdocs\kawaguchi\apps\modules\Account\controllers\D‌​ownPaymentAp.php line: 301
$this->db->insert(T_AccountPayableHeader, $PYHeader);
//print_r($PYParentID);die;
$PYParentID = $this->db->insert_id();
$detailPayment = $detail->first_row("array");
$payableID = $vendor->first_row("array");
$PYDetail = array(
T_AccountPayableDetail_RecordStatus => "",
T_AccountPayableDetail_RecordUpdatedOn => date('Y-m-d g:i:s',now()),
T_AccountPayableDetail_RecordUpdatedBy => $this->ezrbac->getCurrentUserID(),
T_AccountPayableDetail_RecordUpdatedAt => $this->input->ip_address(),
T_AccountPayableDetail_PRI => $PYParentID,
T_AccountPayableDetail_DocTypeID => $headerData[T_MasterDataDownPayment_DocName],
T_AccountPayableDetail_DocNo => $headerData[T_MasterDataDownPayment_DocNo],
T_AccountPayableDetail_DocDate => $headerData[T_MasterDataDownPayment_DocDate],
T_AccountPayableDetail_DueDate => "",
T_AccountPayableDetail_DaysOverdue => "",
T_AccountPayableDetail_InvoiceAmount => $headerData[T_MasterDataDownPayment_Amount],
T_AccountPayableDetail_AmountPaid => $headerData[T_MasterDataDownPayment_TotalAmount],
T_AccountPayableDetail_AmountOutstanding => "",
T_AccountPayableDetail_Bank => $headerData[T_MasterDataDownPayment_BankAccountNo],
T_AccountPayableDetail_SchedulePayment => "",
T_AccountPayableDetail_PONo => $detailPayment[T_MasterDataDownPaymentDetail_PoNo],
);

Access Certain Key Value in PHP Array

I am new to PHP and got confused, I wrote a PHP script to log the server environment variables when user make request, and my code looks like this:
<?php
$req_dump = print_r($_SERVER, TRUE);
$fp = fopen('/tmp/request.log', 'a');
fwrite($fp, $req_dump);
fclose($fp);
echo "hello world";
However, the output looks like below:
Array
(
[HTTP_USER_AGENT] => anaconda/13.21.195
[HTTP_HOST] => 10.0.188.97
[HTTP_ACCEPT] => */*
[HTTP_X_ANACONDA_ARCHITECTURE] => x86_64
[HTTP_X_ANACONDA_SYSTEM_RELEASE] => Red Hat Enterprise Linux
[HTTP_X_RHN_PROVISIONING_MAC_0] => eth0 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_1] => eth1 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_2] => eth2 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_3] => eth3 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_4] => eth4 00:02:C9:4F:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_5] => eth5 00:02:C9:4F:xx:xx
[PATH] => /sbin:/usr/sbin:/bin:/usr/bin
[SERVER_SIGNATURE] => <address>Apache/2.2.15 (Red Hat) Server at 10.0.188.97 Port 80</address>
[SERVER_SOFTWARE] => Apache/2.2.15 (Red Hat)
[SERVER_NAME] => 10.0.188.97
[SERVER_ADDR] => 10.0.188.97
[SERVER_PORT] => 80
[REMOTE_ADDR] => 10.0.188.212
[DOCUMENT_ROOT] => /var/www/html
[SERVER_ADMIN] => root#localhost
[SCRIPT_FILENAME] => /var/www/html/ks.php
[REMOTE_PORT] => 59188
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /ks.php/images/install.img
[SCRIPT_NAME] => /ks.php
[PATH_INFO] => /images/install.img
[PATH_TRANSLATED] => /var/www/html/images/install.img
[PHP_SELF] => /ks.php/images/install.img
[REQUEST_TIME] => 1402439673
)
How I tried to access the array:
FYI, here is the code how I tried to access that array:
# ks.php
<?php
$Table = array(
"00:02:C9:10:aa:bb" => "10.0.188.91",
"00:02:C9:4F:aa:bb" => "10.0.188.92",
"00:02:C9:53:aa:bb" => "10.0.188.93",
"00:02:C9:56:aa:bb" => "10.0.188.94",
"00:02:C9:53:aa:bb" => "10.0.188.95",
"00:02:C9:4E:aa:bb" => "10.0.188.96",
"00:02:C9:5A:aa:bb" => "10.0.188.97",
);
?>
...
%post
...
printf 'DEVICE=eth4 \nIPADDR=<?php echo $Table[$_SERVER["HTTP_X_RHN_PROVISIONING_MAC_4"]]; ?>' > /etc/sysconfig/network-scripts/ifcfg-eth4
service network restart
...
%end
The output doesn't look like straight forward to me. Say I want to get the MAC address of ethernet4, and $_SERVER["HTTP_X_RHN_PROVISIONING_MAC_4"] doesn't work for me.
Can anyone help me explain how to achieve that in PHP?
your $_SERVER['HTTP_X_RHN_PROVISIONING_MAC_4'] output is eth4 00:02:C9:4F:xx:xx which also has a prefix eth4 where as your $Table has 00:02:C9:4F:aa:bb which makes the keys mismatch and actually you are trying to get $Table['eth4 00:02:C9:4F:xx:xx'] which is non existent in your $Table array
Try this:
// We are splitting the mac address by space so that $macAddress contains '00:02:C9:4F:xx:xx' and $eth contains eth4
list($eth,$macAddress) = explode(' ',$_SERVER['HTTP_X_RHN_PROVISIONING_MAC_4']);
// Make sure the value in $macAddress => 00:02:C9:4F:xx:xx is 00:02:C9:4F:aa:bb or change your array accordingly
$Table = array(
"00:02:C9:10:aa:bb" => "10.0.188.91",
"00:02:C9:4F:aa:bb" => "10.0.188.92",
"00:02:C9:53:aa:bb" => "10.0.188.93",
"00:02:C9:56:aa:bb" => "10.0.188.94",
"00:02:C9:53:aa:bb" => "10.0.188.95",
"00:02:C9:4E:aa:bb" => "10.0.188.96",
"00:02:C9:5A:aa:bb" => "10.0.188.97",
);
$finalAddress = $Table[$macAddress];
printf 'DEVICE=eth4 \nIPADDR=<?php echo $finalAddress ; ?>' > /etc/sysconfig/network-scripts/ifcfg-eth4 '
If you just save the array, it becomes like a useless print out. To make it accessible, use json_encode when you save it:
$fp = fopen('/tmp/request.log', 'w');
fwrite($fp, json_encode($_SERVER));
fclose($fp);
Note how I removed the print_r since it’s unnecessary for a task like this. I also changed fopen to overwrite the file using w instead of a so the saved JSON is valid.
Then when you open the file, just use json_decode like this:
$server_variables_json = file_get_contents('/tmp/request.log');
$server_variables = json_decode($server_variables_json , true);
Then $server_variables is an actual array you can act on like this:
if (array_key_exists('HTTP_X_RHN_PROVISIONING_MAC_4', $server_variables)) {
echo $server_variables['HTTP_X_RHN_PROVISIONING_MAC_4'];
}
The if (array_key_exists(…)) is something I put in place to help me debug this locally on my machine since I don’t have HTTP_X_RHN_PROVISIONING_MAC_4 set in my $_SERVER values.
A simple check I did locally to debug this—since I don’t have HTTP_X_RHN_PROVISIONING_MAC_4 in my setup—was just to get the HTTP_HOST like this:
if (array_key_exists('HTTP_HOST', $server_variables)) {
echo $server_variables['HTTP_HOST'];
}
If you want to put the var $_SERVER["HTTP_X_RHN_PROVISIONING_MAC_4"], don't forgot the quotes.
You need to use quotes to identify a non-numeric index:
echo $_SERVER['HTTP_X_RHN_PROVISIONING_MAC_4'];
You can get more basic information from the docs themselves.
Edit: I am not sure what you mean:
<?php
$array=array(
'HTTP_X_RHN_PROVISIONING_MAC_0' => 'eth0 B4:99:BA:07:xx:xx',
'HTTP_X_RHN_PROVISIONING_MAC_1' => 'eth1 B4:99:BA:07:xx:xx',
'HTTP_X_RHN_PROVISIONING_MAC_2' => 'eth2 B4:99:BA:07:xx:xx',
'HTTP_X_RHN_PROVISIONING_MAC_3' => 'eth3 B4:99:BA:07:xx:xx',
'HTTP_X_RHN_PROVISIONING_MAC_4' => 'eth4 00:02:C9:4F:xx:xx',
'HTTP_X_RHN_PROVISIONING_MAC_5' => 'eth5 00:02:C9:4F:xx:xx'
);
echo "Printing just a single element.\r\n";
echo $array['HTTP_X_RHN_PROVISIONING_MAC_4'];
echo "Printing the whole variable:\r\n";
print_r($array);
?>
Outputs the following:
Printing just a single element.
eth4 00:02:C9:4F:xx:xx
Printing the whole variable:
Array
(
[HTTP_X_RHN_PROVISIONING_MAC_0] => eth0 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_1] => eth1 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_2] => eth2 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_3] => eth3 B4:99:BA:07:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_4] => eth4 00:02:C9:4F:xx:xx
[HTTP_X_RHN_PROVISIONING_MAC_5] => eth5 00:02:C9:4F:xx:xx
)

Add EC22 security rule via AWS PHP SDK2

The script is allocating an IP but I'm not seeing the security rule in the GUI. No errors are being thrown. Here is the code snippet I am using:
$config = aws_setup();
$ec2Client = \Aws\Ec2\Ec2Client::factory($config);
$gmodel = $ec2Client->allocateAddress();
$args = array('GroupName' => 'www', 'IpPermissions' => array(array('IpProtocol' => 'tcp', 'FromPort' => 22, 'ToPort' => 22)), 'IpRanges' => array('CidrIp' => array($gmodel->get('PublicIp') . '/32')));
$ec2Client->authorizeSecurityGroupIngress($args);
Got the right syntax for the 'args' variable:
$args = array('GroupName' => 'www', 'IpPermissions' => array(array('IpProtocol' => 'tcp', 'FromPort' => 22, 'ToPort' => 22, 'IpRanges' => array(array('CidrIp' => $gmodel->get('PublicIp') . '/32')))));
The rule is now being added to the security group.

Unknown authorization header error with Buzz API - Using Zend OAuth

Here's the response I keep getting when trying to create a new
activity:
{"error":{"errors":[{"message":"Unknown authorization
header","locationType":"header","location":"Authorization"}],"code":
401,"message":"Unknown authorization header"}}
Here's the request I sent (for debugging):
POST /buzz/v1/activities/#me/#self?alt=json HTTP/1.1
Host: www.googleapis.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Content-Type: application/json
Authorization: OAuth
realm="",oauth_consumer_key="eawp.com",oauth_nonce="ce29b04ce6648fbb92efc8f08c1c0091",oauth_signature_method="HMAC-
SHA1",oauth_timestamp="1277934794",oauth_version="1.0",oauth_token="1%2FcBzo5ckGvCAm3wLWh1SDH3xQNoW--
yek1NVfUa1Qqns",oauth_signature="CUezSiMbvxyN1BTeb3uROlIx8gA%3D"
Content-Length: 86
{"data":{"object":{"type":"note","content":"Using OAuth with Twitter -
PHP Example"}}}
All the other requests to get the access_token worked just fine, but
now I'm not too sure why it's not working.
** Update
To assist with the debugging a bit more, here is the code in question:
$config = array(
//'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
//'version' => '1.0',
//'signatureMethod' => 'HMAC-SHA1',
'callbackUrl' => $callback,
'siteUrl' => $url,
'consumerKey' => $consumerKey,
'consumerSecret' => $consumerPass
);
$statusMessage = $title;
$token = unserialize($accessToken);
$client = $token->getHttpClient($config);
$client->setUri('https://www.googleapis.com/buzz/v1/activities/#me/
#self?alt=json');
$client->setMethod(Zend_Http_Client::POST);
$client->setEncType(Zend_Http_Client::ENC_FORMDATA);
$client->setHeaders('Content-Type: application/json');
$data = array(
'data' => array(
'object' => array(
'type' => 'note',
'content' => $statusMessage,
),
),
);
$dataXml = "<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:activity='http://activitystrea.ms/spec/1.0'>
<activity:object>
<activity:object-type>http://activitystrea.ms/schema/1.0/
note</activity:object-type>
<content type='html'>$statusMessage<content>
</activity:object>
</entry>";
//$client->setRawData($dataXml);
$client->setRawData(Zend_Json::encode($data));
//$client->setParameterPost("content", $statusMessage);
$response = $client->request();
** As you can see, I did a bit of testing with both the xml+atom and
json requests - not much luck with either.
Can you see anything clearly wrong there? And another reminder that I
am using Zend_Oauth.
I have some problem
Use option:
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING
in your $config array
After this change my problem was solved
PS More code:
$OAuthConfiguration = array(
'version' => '1.0',
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING,
'signatureMethod' => 'HMAC-SHA1',
'callbackUrl'=>'####',
'requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken',
'authorizeUrl' => 'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken',
'accessTokenUrl' => 'https://www.google.com/accounts/OAuthGetAccessToken',
'consumerKey' => '####',
'consumerSecret' => '####',
);
$OAuthConsumer = new Zend_Oauth_Consumer($OAuthConfiguration);
//authorizeOAuth
$params = array(
'domain'=>'####',
'scope'=>'https://www.googleapis.com/auth/buzz'
);
$token = $OAuthConsumer->getRequestToken($params);
$_SESSION['token']['buzz'] = serialize($token);
$OAuthConsumer->redirect($params);
//callbackOAuth
if (!empty($_GET) && isset($_SESSION['token']['buzz'])) {
$token = $consumer->getAccessToken(
$_GET,
unserialize($_SESSION['token']['buzz'])
);
unset($_SESSION['token']);
return serialize($token);
} else {
return false;
}

Categories