I want to share my status to google plus.
I followed the google api, but i am getting the unauthorized error. I am trying to fix it for more then 2 days, but i could't..
i read this answer, i download and test the api, still not working for me.
401 Unauthorized access when posting Google+ Moments with PHP Client
You can check here,
https://code.google.com/p/google-api-php-client/source/browse/trunk/examples/moments/simple.php
In this trunk file, still they are calling the Google_PlusMomentsService.php
i tried the following code, but still not works - https://developers.google.com/+/api/latest/moments/insert
here is the live link which i am testing: http://webscarlets.in/projects/babblesuite/gplus/index.php
this is code i am using to share the status
$target = new Google_ItemScope();
$target->url = 'https://developers.google.com/+/plugins/snippet/examples/thing';
$moment = new Google_Moment();
$moment->type = "http://schemas.google.com/AddActivity";
$moment->target = $target;
// Execute the request
$moments->moments->insert('me', 'vault', $moment);
print '<p>Created an AddActivity moment</p>';
can anyone fix it please.
Thanks to all
You need to authorize the user in the PHP client and request visible actions (e.g. AddActivity) before you can write app activities to a user's profile. Because you're using the older sample, you probably aren't setting requestvisibleactions either in the button or in your OAuth2 flow.
Try starting here:
https://developers.google.com/+/quickstart/php
This is the latest PHP starter and has been verified to work. If you really, really, want to use the older code you've shared, please share the sign-in button markup, e.g.:
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="CLIENT_ID"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>
Because I'm guessing you're missing the line: data-requestvisibleactions...
Related
I'm using OctoberCMS based on Laravel freamwork.
I would like to have option on my website "sign in with google account".
So I went to https://developers.google.com/identity/sign-in/web/devconsole-project
and I fallowed all of the steps to "Authenticate with a backend server".
Becouse I don't have ssh access to my domain ( I cannot install library using Composer), so I downloaded Google API Client Library for php in .zip .
I unpacked it to 'plugins/nameOfMyplugin/google'.
And I got stuck,becouse I don't have any idea how to Send the ID token to my server and to validate it with those library, then I would like to create new user in my db if not exist in my rainlab.user.plugin.
Thank You for any help.
I have solved it.
In octoberCMS there is no reason for connect with google api by Your own, better solusion is download already made plugin(octobercms.com/plugin/flynsarmy-sociallogin) which is working.
I just downloaded octobercms.com/plugin/flynsarmy-sociallogin, but as I said it before, got some problems with login into my website.
I sow that each 12 minutes break between log out and log into my website I can login. When I tried to log into after in 11 minutes after log out it didn't work.
I went to my backend/ settings / logs /event logs and sow that
Cannot handle token prior to 2017-04-19T08:27:14+0000 in public_html/plugins/flynsarmy/sociallogin/vendor/firebase/php-jwt/src/JWT.php on line 124.
It's mean that my server time have 12 minutes late.
There are 2 ways to solve it:
First one not good for safety reasons:
SET in plugins/flynsarmy/sociallogin/vendor/firebase/php-jwt/src/JWT.php
public static $leeway = x;
Where x are secunds, in my example
or add difference of time in this if in from 123 :
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway +
**720**)) {
throw new BeforeValidException('Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
);
}
But as I said... it's not safety...
Second solution is to set time on server in right way.
There is a lot of solutions how to do it:
http://www.inmotionhosting.com/support/website/php/update-local-php-settings
https://help.directadmin.com/item.php?id=52
http://forum.directadmin.com/showthread.php?t=1817
For some reason when I call the following code:
echo file_get_contents('http://gdata.youtube.com/feeds/api/videos/wGG543FeHOE?v=2&alt=json');
I get the following image: http://i.ytimg.com/vi/UKY3scPIMd8/sddefault.jpg
This was working a few days ago - have Youtube started to restrict PHP access to their API?
For anyone else who gets this problem - see https://developers.google.com/youtube/v3/getting-started. Basically they've deprecated the free4all api and are now limiting it to token access. Its quite easy to get a token and once you have one just call:
https://www.googleapis.com/youtube/v3/videos?id=ID&key=YOUR__KEY&part=snippet,contentDetails,statistics,status
Had a look at quite a few posts on stack and the cpanel forum but still cant seem to find a solution.
Im trying to retreive information via an api call but it just always seems to fail. I know its to do with the url 404'ing but not sure how to fix.
I am using the the XMl API class:
https://github.com/CpanelInc/xmlapi-php/
The code I have is:
$this->load->library('xmlapi');
$xmlapi = new xmlapi(XMLAPI_HOST);
$xmlapi->password_auth(CPANEL_USER, CPANEL_PASSWORD);
$xmlapi->set_debug(1);
echo '<pre>';
print_r($xmlapi->accountsummary(CPANEL_USER));
echo '</pre>';
The above outputs the xml array. In the error_notice it says:
HTTP error 404, The requested page was not found.
Thats fine. So I echo out the url it uses which 404's:
http://mysite.co.uk:2082/xml-api/accountsummary
The cpanel docs are a little awkward to navigate but just cant find anything on the actual url structure, besides its the class that compiles the url. ive tried adding www, tried an ip etc but no idea why its erroring.
Also if it helps im accessing a normal cpanel account, not a WHM admin and its through http.
Thanks for reading, any help guidance on getting it working would be appreciated.
The issue you are experiencing is that you are attempting to use the accountsummary function from cPanel ports (2082/2083). The accountsummary function is limited to the administrator accounts since this function is designed to provide administrative api level access for pulling account information from any user on the server.
To access the accountsummary api, you will need to call the accountsummary api from the following url:
https://$SERVER_IP:2087/xml-api/accountsummary?user=$USERNAME
You will need to replace $SERVER_IP and $USERNAME with their respective values.
http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/ShowAccountInformation
I am working on my second Facebook App and seem to have run into a problem. On my first App, I used
$user_id = $facebook->require_login();
to get the ID of the user that was using my app. It worked great, and still does. However, on my second App, I used the same thing but keep getting the old 500 Internal Server Error. ( Using Opera as browser ) Not sure why, since the exact same code works on the other App. Here it is:
<?php
require_once('facebook.php');
$appapikey = 'APIKEYHERE';
$appsecret = 'SECRETKEYHERE';
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();
echo $user_id;
echo "Hello!";
?>
I have checked the server and PHP logs, none of them report any errors.
500 internal server error ussually comes from an error in your code, not browser related anyway.
Also, the API should work just fine. Try replacing
include 'facebook.php';
with
require_once('facebook.php');
Also, is this everything you have in the code?
How long ago did you write your first app? Facebook has got rid of the old APIs (although left them there for old apps to continue to work), but all new apps have to use the Graph API instead.
Take a look here for more information.
http://developers.facebook.com/docs/guides/canvas/
Also, take a look at this documentation.
http://developers.facebook.com/docs/api
Howdy. I've been tasked with making a Facebook game, but I'm new to Facebook development, so I'm just getting started. Apologies in advance if this is a no-brainer to people.
I'm having trouble following all the examples I see on sites, and I keep running into missing pages in the Facebook documentation when I am trying to read up. I think it's because there's a new version of the PHP Client Library for Facebook, and everything I'm finding is referring to the old client.
For instance, I see this code in a lot of examples:
require 'facebook.php';
$facebook = new Facebook( array( 'appId' => '(id)', 'secret' => '(secret)' ) );
$facebook_account = $facebook->require_login();
...but there's no "require_login()" in the client library provided in the facebook.php file.
From what I can tell, it looks like Facebook has very recently rolled out some new system for development, but I don't see any sample code anywhere to deal with it. The new library comes with an "example.php" file, but it appears to be only for adding "Log in with Facebook" functionality to other sites (what I'm assuming is what they mean by "Facebook Connect" sites), not for just running apps in a Canvas page on Facebook itself.
Specifically, what I need to do is let users visit an application page within Facebook, have it bring up the dialog box allowing them to authorize the app, have it show up in their "games" page, and then have it pass me the relevant info about the user so I can start creating the game. But I can't seem to find any tutorials or examples that show how to do this using the new library. Seems like this should be pretty straightforward, but I'm running into roadblocks.
Or am I missing something about the PHP client library? Should require_login() be working for me, and there's something broken with my implementation, such as having the wrong client library or something? I downloaded from GitHub yesterday, so I'm pretty sure I have the most recent version of the code I have, but perhaps I'm downloading the wrong "facebook.php" file...?
The following is a rewrite of the old require_login function. It exactly duplicates the old functionality.
function facebook_require_login($required_permissions = '')
{
global $facebook; // NOTE GLOBAL FACEBOOK OBJECT, MUST ALREADY BE INSTANTIATED
$user = $facebook->get_loggedin_user();
$has_permissions = true;
if ($required_permissions) {
$facebook->require_frame();
$permissions = array_map('trim', explode(',', $required_permissions));
foreach ($permissions as $permission) {
if (!in_array($permission, $facebook->ext_perms)) {
$has_permissions = false;
break;
}
}
}
if ($user && $has_permissions) return $user;
$facebook->redirect(
$facebook->get_login_url(Facebook::current_url(), $facebook->in_frame(),
$required_permissions));
}
phpfour solution is the only correct one - since it utilizes the new php-sdk library from github.
The best solution is to edit the new facebook.php and add a require_login() function (so all existing pages who rely on it can stay the same)
public function require_login(){
if ( !$this->getSession() ) {
$url = $this->getLoginUrl( array(
'canvas' => 1,
'fbconnect' => 0
));
echo "<script type='text/javascript'>top.location.href = '$url';</script>";
}
else
return $this->getUser();
}
The new php script on git hub is a wraper for facebooks api, graph I presume but I've seen code for fql too so who knows. The forums are currently down and IRC was dead when I went across. I have been looking for the same solution as your require authorisation to call ->api(\me). Since the script extends another class if I remember right, you could try using the reflection class/function to see what methods are available. Hopefully some solid documentation is on its way! Please let me know if you solve this. (Sorry for poor formatting I'm on my mobile)
Well, I have been able to find a solution to the problem of authorizing application using the new PHP SDK. You can check my blog post here.
In short, you will need to get an authenticated session and then you can call the functions to get the logged in user's ID. In this case, you will call the "/me" path from the Graph API.