I have used this url http://pinterestapi.co.uk/username/pins for getting the pins from my account . Previously it is working but now it is not giving proper response . The output is {"body":[],"meta":{"count":0}} . At the starting it have some data for the key "Body" . So Based on that I have parsed the json . Please tell me how to solve this problem . Platform is **iOS** .
Related
I want to control (read) statuses of a smart swithc associated in my google home app. I did a similat application using the smartdevice api and i am able to control a google thermostat.
Now back to the smart switch, i read that I need to use the homegraph api (correct me if i'm wrong). I followed the docs on google api and tried many times with oauth , setting the scope https://www.googleapis.com/auth/homegraph (as per this link https://developers.google.com/identity/protocols/oauth2/scopes). When I send the request to get the token i receive an error that this scope is not authorised.
Authorization Error
Error 400: invalid_scope
Some requested scopes cannot be shown: [https://www.googleapis.com/auth/homegraph]
my code is below, can anyone lighten me up what is the issue? I searched and there is no php code example fro this type of implementation with the homegraph.
require_once('vendor/autoload.php');
$client = new Google\Client();
$client->setAuthConfig('client_secret_oauth.apps.googleusercontent.com.json');
$client->addScope( 'https://www.googleapis.com/auth/homegraph' );
$client->setRedirectUri('https://' . $_SERVER['HTTP_HOST'] . '/homegraph-api/oauth2callback.php');
$client->setAccessType('offline');
$client->setIncludeGrantedScopes(true);
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
// code for google client api to interact with homegraph
Thank you.
Good Day, I Try to Get Channel ID using service account, because I´m using it on other scopes on my project. But when I do request process its give me the service account information. i´m using php btw
Many thanks in advance and any help will be appreciated.
p.d. i´m replace real account info for dummy text.
And of Course the code :
$credentials_file = $this->key_dir . $this->key_file['title'];
$client = new \Google_Client();
$client->setAuthConfig($credentials_file);
$client->addScope('https://www.googleapis.com/auth/youtube');
$client->setApplicationName("Youtube Analytics");
$client->refreshTokenWithAssertion();
$token = $client->getAccessToken();
$accessToken = $token['access_token'];
if (!empty($accessToken)) {
$service = new \Google_Service_YouTube($client);
$data = $service->channels->listChannels('id,snippet', array('mine' => 'true'));
echo "id: " . $data->items[0]->id . "<br>";
echo "Kind: " . $data->items[0]->kind . "<br>";
echo "Snippet -> title : " . $data->items[0]->snippet['title'] . "<br>";
}
AFAIK, Youtube API doesn't support Service Account Flow. As described in the document :
The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Data API does not support this flow. Since there is no way to link a Service Account to a YouTube account, attempts to authorize requests with this flow will generate a NoLinkedYouTubeAccount error.
Also in the Youtube v3 Google Service Account Access issue, "There are no plans to add support for Service Account authorization to YouTube Data API v3 calls." As stated in the related SO question #21890982 and #21057358 : you'll need your own account for that and you can create an authentication for services using V3 without user intervention.
Hope this helps.
Right now I generate authentication headers using a website - OAuth tool. Then I create the following code:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" .
'Authorization: OAuth oauth_consumer_key="343432dsddsf", ' .
'oauth_nonce="3432fsdfsdf", ' .
'oauth_signature="423fsdfsdfsdf%3D", ' .
'oauth_signature_method="HMAC-SHA1", ' .
'oauth_timestamp="1431435892", ' .
'oauth_version="1.0"'
)
);
//191683771
$context = stream_context_create($opts);
$source = #file_get_contents('https://api.twitter.com/1.1/statuses/user_timeline.json?count=200&user_id=112344123', false, $context);
To get the JSON data.
It works, but I want the user_id parameter to be changed. I have the whole array of users for which I want to retrieve this data.
But then, I can't do that as I would have to generate authentication headers for all users myself.
Is there a way to solve this?
I am using the Purchase REST API call to check if the user has purchased an item. I noticed that sometimes the call is not successful. It returns the error message "Serving Limit Exceeded". But if I make the call again, it returns a successful result. Are there any more errors like this that I would need to handle? I did not find this documented anywhere.
"https://www.googleapis.com/androidpublisher/v1/applications/" . $packageName . "/subscriptions/" . $prodID . "/purchases/" . $token . "?access_token=" . $r ['access_token'];
I'm trying to promote my app using app center but from the Web preview I can't visit the web site.
The link that is called is http://www.myappsite.it/?fb_source=appcenter&fb_appcenter=1&code=a_long_string
From the index.php of myappsite I use this peace of php code to get the user coming from facebook
$code = $_REQUEST["code"];
if($_REQUEST['state'] == $_SESSION['state'] && !$user && strlen($code) > 0)
{
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $appId . "&redirect_uri=" . urlencode("http://www.myappsite.it/") .
"&client_secret=" . $secret . "&code=" . $code;
$response = #file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token'];
$user = json_decode(file_get_contents($graph_url));
echo("Hello " . $user->name);
}
but $params['access_token'] is empty because the $token_url returns
{
"error": {
"message": "Error validating verification code.",
"type": "OAuthException",
"code": 100
}
}
how can I get the user logged in from tha app center preview web page?
From the Authenticated Referrals part of the docs (the App centre counts as an authenticated referral)
See A special consideration when using the Query String setting:
If you would like to use the server-side authentication flow it is
important to make sure you are passing the redirect_uri parameter
correctly when exchanging your code for an access token. You should
set your redirect_uri parameter to the click-through URL to your site
without the code parameter. In most cases the URL will look something
like:
http://www.example.com/?fb_source=search&code=CODE_HERE Once you
strip the code parameter it will become:
http://www.example.com/?fb_source=search which is the value that
should be set in redirect_uri. Please make sure that this logic is
dynamic as the query parameters appended to your click-through URL may
be subject to change.
Using your example from above, this means your redirect_uri parameter should be http://www.myappsite.it/?fb_source=appcenter&fb_appcenter=1
As Igy said:
http://www.example.com/?fb_source=search&code=CODE_HERE Once you strip the code parameter it will become:
http://www.example.com/?fb_source=search
However if you are redirecting with this url it will need to be url encoded otherwise the ? will stop the redirect parameter and add the fb_source to your request.
It should look like this when sent out:
http%3a%2f%2fwww.example.com%2f%3ffb_source%3dappcenter%26fb_appcenter%3d1
(Which is what Marco had already done which is why he is now happy that it works)
urlencode("http://www.myappsite.it/")