Evernote Integration With PHP - php

I have successfully done with the authentication of Evernote with PHP.
And I have got this response.
Array ( [oauth_token] => S=s1:U=6316e:E=144fcfdfdb9:C=13da54cd1ba:P=185:A=maheshchari-2599:V=2:H=6da806fe92b9289cf0334f04e2afdc55 [oauth_token_secret] => [edam_shard] => s1 [edam_userId] => 405870 [edam_expires] => 1395813907897 [edam_noteStoreUrl] => https://sandbox.evernote.com/shard/s1/notestore [edam_webApiUrlPrefix] => https://sandbox.evernote.com/shard/s1/ )
Now, I want the list of notebooks of the user which has been authenticated with evernote.
I have done a lot of research online but I couldnt find any thing which helps, I have came to know that guid is necessary to get the list of notebooks.
From where I can find that? And how can i access the notestore and userstore?
How can i call the functions of notestore and userstore to fetch the data of user's account and user's notes in php?
Thanks in Advance.

Using the Evernote SDK for PHP, you can list notebooks like the way below:
$client = new Client(array('token' => $authToken));
$noteStore = $client->getNoteStore();
$notebooks = $noteStore->listNotebooks();
All the API references can be found here.
Also, you shouldn't make your token public. Please make sure your token string you put can't be used any more. If you need more help on this, you can get supports from Evernote developer support.

https://github.com/evernote/evernote-sdk-php
go to this link and download this zip then go to sample folder then go to client folder and run EDAMTest.php page.
and add authtoken.

Related

PayPal - Cancel Pre-approved Payment using API and PA key

Quetion:
How would I cancel a pre-approved payment using PayPal's API operations? I have the Pre-approval key of the payment to be cancelled but I can't find a way to do it.
I did some digging over the internet and found this CancelPreapproval API Operation but that document is not very helping for a starter like me. Few things are missing like what would be the link where I'd send the cancel request? Can't find any example. Need help.
I did tried cancelling the payment by using this code but it fails.
$security_user_id = $neworder->security_user_id;
$security_password = $neworder->security_password;
$security_signature = $neworder->security_signature;
$security_application_id = $neworder->security_application_id;
$headers_array = array("X-PAYPAL-SECURITY-USERID" => $security_user_id,
"X-PAYPAL-SECURITY-PASSWORD" => $security_password,
"X-PAYPAL-SECURITY-SIGNATURE" => $security_signature,
"X-PAYPAL-APPLICATION-ID" => $security_application_id,
"X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
);
$pay_result = wp_remote_request('https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval', array('method' => 'POST', 'timeout' => 20, 'headers' => $headers_array, 'body' => $maincode));
This PayPal PHP SDK will make it very quick and easy for you. Just extract it into your project structure as you would any other class, and make sure to setup the config file correctly with your own sandbox and/or live PayPal credentials.
Then you can look in the /templates and you'll see a CancelPreapproval.php setup and ready to go. It'll be fully functional. All you'll have to do is plug in your preapproval key and it'll handle the rest for you successfully.
There are lots of /samples and there is a file in /templates for pretty much every API call PayPal has.
You can get this done within minutes using that class. Let me know if you have any specific questions about it.

Google Play scraper

I'm trying to develop a Play Store reviews scraper in PHP and I need to make a POST request to this URL https://play.google.com/store/getreviews, and I saw the parameter post with firebug.
I am using Goutte library and here is my code:
require_once 'goutte.phar';
use Goutte\Client;
$client = new Client();
$params = Array(
"id" => "com.trello",
"pageNum" => 2 ,
"reviewSortOrder" => 2 ,
"reviewType" => 0,
"xhr" => 1
);
$crawler = $client->request('POST' , 'https://play.google.com/store/getreviews', $params);
The problem is that the request returns nothing. Is there anyone who already faced this problem and solved it?
I don't think this is possible. Google Play changed their review interface last year. They now have a "token" parameter which is missing here. I have worked before to try and work out what seeds this (see Google play review scraping changes) but I can't figure it out. After a number of attempts to hit that webservice with an incorrect request (presumably without the token) Google Play starts blocking your IP, that's why you'll be getting nothing back after a while (and won't be able to open Google Play in your browser either). If you find a solution, let me know!
This URL works for me, with the form-post data in your example.
https://play.google.com/store/getreviews?authuser=0

hotmail: user authentication and contact retrieval with PHP

I am trying to write a PHP script that will allow me to do two things:
Allow users to use their Hotmail (I think its called 'Live' now?) account to authenticate themselves to a website
Retrieve an authenticated users contact list from Hotmail.
I have trawled the internet for the past 6 hours, looking for at least a working example that I can modify/extend to do the above two things. There are several dozens similar questions asked here on SO for example - NONE of the proffered answers work any more (admittedly, some of the questions were a few years old).
I tried the Microsoft site and downloaded the latest version of their API which seems to evolve at a rather alarming rate. I finally managed to track down an API which has not been deprecated (yet?).
I followed the instructions and when I attempted to authenticate, I was rewarded with the following mesage, for my efforts:
We're unable to complete your request
Windows Live ID is experiencing technical difficulties. Please try again later.
I immediately tried the online version of the demo and perhaps unsurprisingly, that worked like a charm.
As an aside, I managed to implement the same functionality for Yahoo and GMail, using their OPEN APIs, under an hour each. Now, it is possible that my unmitigated hatred of all things proprietary (sorry make that Microsoft), is causing me to lose the plot a little here.
Has anyone ACTUALLY (in 2012) managed to get a working sample in PHP that allows:
Hotmail (live?) user authentication
Hotmail user contact email retrieval
If you have, a code snippet, or a link to where I can find such a snippet would be very useful, as I have so far, wasted a whole afternoon trying to work the Microsoft Live API via PHP.
PS: No, I'm not interested in OpenInviter, its broken.
i wrote my own oauth library based around a single array for each service provider. this array contains all of the data required to perform authentication and retrieve user data. the array i use for msdn (ie. hotmail, outlook, xbox, msn) is:
$msdn = array
(
'oauth_version' => '2',
'oauth_method' => 'GET',
'redirect_user_params' => array
(
'url' => 'https://oauth.live.com/authorize',
'response_type' => 'code',
'http_params' => array
(
'url',
'client_id',
'redirect_uri',
'response_type',
'scope',
'state'
)
),
'obtain_access_token_params' => array
(
'url' => 'https://oauth.live.com/token',
'grant_type' => 'authorization_code',
'http_params' => array
(
'url',
'client_id',
'client_secret',
'code',
'grant_type',
'redirect_uri',
'scope'
)
),
'scope' => 'wl.signin wl.basic',
'obtain_user_data_params' => array
(
'url' => 'https://apis.live.net/v5.0/me',
'http_params' => array
(
'url',
'access_token',
'scope'
)
),
'client_id' => 'xxxxx', // = oauth_consumer_key in oauth 1.0 lingo
'client_secret' => 'xxxxxxxxxxxxxxx',
'readme_url' => 'http://msdn.microsoft.com/en-us/library/live/hh243647.aspx'
);
the parameters for each of the three oauth stages (ie "redirect user", "obtain access token" and "obtain user data") are in the http_params arrays. in the case of msdn these parameters end up in the query query string of the url that i send out with curl (since msdn only accepts GET, not POST).
i haven't tried retrieving the user's contact address book, but this would just be a case of extending the scope element with whatever extra information you require (documented here http://msdn.microsoft.com/en-us/library/live/hh243646.aspx). as you can see from the http_params arrays, the scope parameter is used in each of the three oauth stages.
Try out a Hotmail/MSN/Live import on the CloudSponge test drive to see if that's the user experience you're hoping for.
If it works for you, you can use our widget or our API. If you want to use the API, we have a PHP wrapper already written for your convenience.
Please confirm your callback url is with http:// if you only put www.domain.com then get this issue..

Need to call simple request from soundcloud API using the wrapper

I am using the main soundcloud wrapper (https://github.com/mptre/php-soundcloud) to try and pull the tracks off my account onto my website. I had the whole thing working great but just by accessing a query (my username has changed and isn't as unique, so i need to change the query). So what I need to request is exactly this "https://api.soundcloud.com/users/isound604/tracks.json" and if you check in the API console you will see it returns my tracks.
My problem is that i don't know how to make this request with the wrapper. I used to use:
$string = $soundcloud->get('tracks', array('q' => 'beatmanshan', 'order' => 'created_at'));
but the new request doesn't seem to work in that function. Can anybody shed any light on this issue? Please and thank you in advance! Let me know if you need any more info.
Have you already authenticated ok using the api? To check
$my_details = json_decode($soundcloud->get('me'));
Should return your account details
If so have you tried
$string = $soundcloud->get('users/isound604/tracks', array('order' => 'created_at'));

Using Twitter OAuth for automatic status update

I want my website to automatically post status updates to a particular twitter account using OAuth in PHP.
I test this using a URL
www.mysite.com/update_status
but it asks me for "user name" and "password", which is fine when I am testing it. But my website will not be able to insert this user name and password before posting the status update.
So the question is how can a website which is in the server, automatically post a status update to an account without user filling out the user name and password.
Is there any way to bypass this? I tried saving oAuth tokens, but it's not working.
Thank you for your answer in advance!
My recommendation:
1) Use a PHP library like http://github.com/abraham/twitteroauth.
2) Select your app on http://dev.twitter.com/apps and click on "My Access Token".
3) Us that access token as described on http://dev.twitter.com/pages/oauth_single_token.
Just tried this and it WORKS! And its SO SIMPLE to use!!
http://ditio.net/2010/06/07/twitter-php-oauth-update-status/
Got it working in under 5mins.
xAuth is able to do that, but Twitter only allows it for desktop and mobile apps.
In case you wanna try it, read this article and the API docs.
Try it with zend framework. As of version 1.10.8 minimal code required to post on Twitter is:
$token = new Zend_Oauth_Token_Access;
$token->setParams(array(
'oauth_token' => 'REPLACE_WITH_TOKEN',
'oauth_token_secret' => 'REPLACE_WITH_TOKEN_SECRET'
));
$twitter = new Zend_Service_Twitter(array(
'consumerSecret' => 'REPLACE_WITH_CONSUMER_SECRET',
'accessToken' => $token
));
$response = $twitter->status->update('REPLACE WITH MESSAGE');
All tokens and secrets can be accessed after registering your application on http://dev.twitter.com

Categories