ऐसा लगता है कि एपीआई एक्सप्लोरर वर्तमान में Google को लेखन ऐप गतिविधि के साथ काम नहीं करेगा क्योंकि यह OAUTH2 प्रवाह के अनुरोध अनुरोध फ़ील्ड को पास नहीं कर रहा है। आप अभी भी चीजों को मैन्युअल रूप से कर सकते हैं जैसा कि मैं नीचे वर्णित करूंगा।
सबसे पहले, यह सुनिश्चित करें कि आप अनुप्रयोग गतिविधि प्रकार आप डालने कर रहे हैं के लिए निर्धारित requestvisibleactions साथ साइन-इन बटन प्रदान कर रहे हैं:
वहाँ दो चीजें आप क्या करने की जरूरत है। निम्न उदाहरण दिखाता है कि आप ऐड गतिविधि के साथ में साइन-प्रस्तुत करना होगा:
<div id="gConnect">
<button class="g-signin"
data-scope="https://www.googleapis.com/auth/plus.login"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-clientId="YOUR_CLIENT_ID"
data-callback="onSignInCallback"
data-theme="dark"
data-cookiepolicy="single_host_origin">
</button>
</div>
इसके बाद, आप का निर्माण और एप्लिकेशन गतिविधि लिखने के लिए की आवश्यकता होगी।
:
http://wheresgus.com/appactivitiesdemo
आप प्रलेखन यहां से लगभग गतिविधि प्रकार के सभी सीख सकते हैं:
var payload = {
"target": {
"id" : "replacewithuniqueidforaddtarget",
"image" : "http:\/\/www.google.com\/s2\/static\/images\/GoogleyEyes.png",
"type" : "http:\/\/schema.org\/CreativeWork",
"description" : "The description for the activity",
"name":"An example of AddActivity"
},
"type":"http:\/\/schemas.google.com\/AddActivity",
"startDate": "2012-10-31T23:59:59.999Z"
};
var args = {
'path': '/plus/v1/people/me/moments/vault',
'method': 'POST',
'body': JSON.stringify(payload),
'callback': function(response) {
console.log(response);
}
};
gapi.client.request(args);
आप यहाँ एक लाइव डेमो देख सकते हैं: निम्न उदाहरण इस का उपयोग कर जावास्क्रिप्ट चलता https://developers.google.com/+/api/moment-types
अद्यतन
नोट लाइव डेमो निम्न कोड के साथ अद्यतन किया गया है और आप सीधे फोन कर नहीं किया जाना चाहिए gapi.client.request:
writeListenActivity: function(url){
var payload = {
"type": "http://schemas.google.com/ListenActivity",
}
if (url != undefined){
payload.target = { 'url' : url };
}else{
payload.target = {
"type": "http:\/\/schema.org\/MusicRecording",
"id": "uniqueidformusictarget",
"description": "A song about missing one's family members fighting in the American Civil War",
"image": "https:\/\/developers.google.com\/+\/plugins\/snippet\/examples\/song.png",
"name": "When Johnny Comes Marching Home"
};
}
this.writeAppActivity(payload);
},
writeAddActivity: function(url){
var payload = {
"type":"http:\/\/schemas.google.com\/AddActivity",
"startDate": "2012-10-31T23:59:59.999Z"
};
if (url != undefined){
payload.target = {
'url' : 'https://developers.google.com/+/plugins/snippet/examples/thing'
};
}else{
payload.target = {
"id" : "replacewithuniqueidforaddtarget",
"image" : "http:\/\/www.google.com\/s2\/static\/images\/GoogleyEyes.png",
"type" : "http:\/\/schema.org\/CreativeWork",
"description" : "The description for the activity",
"name":"An example of AddActivity"
};
}
this.writeAppActivity(payload);
},
writeAppActivity: function(payload){
gapi.client.plus.moments.insert(
{ 'userId' : 'me',
'collection' : 'vault',
'resource' : payload
}).execute(function(result){
console.log(result);
});
}
विशेष ध्यान दें
gapi.client.plus.moments.insert कोड है जो gapi.client.request कॉल को प्रतिस्थापित करता है।
ग्रेट, 'requestvisibleactions' जैसा दिखता है समस्या की जड़ है। और [यह पोस्ट] (https://plus.google.com/118276561380249048216/posts/2kMX9Dzaf8V) उचित [diff] (https://code.google.com/p/google-api-php-client/source) तक ले जाता है सर्वर-साइड ओथ प्रमाणीकरण के लिए /diff?spec=svn533&r=533&format=side&path=/trunk/src/auth/Google_OAuth2.php)। जानकारी के लिए धन्यवाद! – mente
@class "replacewithuniqueidforaddtarget" से आपका क्या मतलब है क्या आप यहां एक यादृच्छिक आईडी टाइप करते हैं या कुछ? – Supertecnoboff
लक्ष्य आईडी के लिए, जैसा कि आपने सुझाव दिया है, यह सिर्फ एक यादृच्छिक स्ट्रिंग है। – class