Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Access Ads On The Facebook Graph API #3

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2401929
SOCIALFB-34 Access Ads On The Facebook Graph API
Oct 20, 2011
a42dbf9
SOCIALFB-34 Add More Stats Specific Operations
karthicks Oct 21, 2011
7f3d3b4
Handle reach estimation operation correctly
karthicks Oct 22, 2011
a29c8da
SOCIALFB-34 Handle reach estimation operation correctly
karthicks Oct 22, 2011
c0d422b
Merge branch 'master' of https://github.com/karthicks/spring-social-f…
karthicks Oct 22, 2011
e3f4aa8
SOCIALFB-34 Add Search And Post Operations
karthicks Oct 24, 2011
ba6efee
SOCIALFB-34 Deserialize List Return Values Properly
karthicks Oct 25, 2011
c86f0fa
SOCIALFB-34 Add static modifier back to post type deserializer
karthicks Oct 25, 2011
715fa04
SOCIALFB-34 Flesh Out Targeting And Image Operations
karthicks Oct 26, 2011
41a18cb
SOCIALFB-34 Allow updates of creative, adgroup and campaigns
karthicks Oct 27, 2011
0572aa8
SOCIALFB-34 Allow uploads of image zip files to an account's adimages
karthicks Oct 27, 2011
9c477c8
SOCIALFB-34 Add documentation for the Facebook Ads API
karthicks Oct 27, 2011
1c8b1ef
SOCIALFB-34 Add documentation for the Facebook Ads API
karthicks Oct 27, 2011
21742a5
SOCIALFB-34 Add ad account, campaign and group specific stats
karthicks Oct 27, 2011
8a61113
SOCIALFB-34 Retrieve Ad-Specific Autocomplete Data
karthicks Oct 28, 2011
5be9b2f
SOCIALFB-34 Assign proper values to ad creative type
karthicks Oct 28, 2011
001131a
SOCIALFB-34 Make creative's object id a long
karthicks Oct 29, 2011
743af95
SOCIALFB-34 Utility method for Facebook enumerations
karthicks Oct 31, 2011
397bde0
SOCIALFB-34 Pass actual ad creative type value, not its ordinal
karthicks Oct 31, 2011
d47ac4e
SOCIALFB-34 Serialize Enums Using #toString
karthicks Nov 2, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ configure(javaprojects) {
apply from: "$buildSrcDir/schema-publication.gradle"

springSocialVersion = '1.0.0.RELEASE'
jacksonVersion = '1.8.5'
jacksonVersion = '1.9.0'
jspApiVersion = '2.1'
junitVersion = '4.9'
mockitoVersion = '1.8.5'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.springframework.social.facebook.api;

public class Action {
private String name;
private String link;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLink() {
return link;
}

public void setLink(String link) {
this.link = link;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.springframework.social.facebook.api;

import org.springframework.social.OperationNotPermittedException;

@SuppressWarnings("serial")
public class ConnectionException extends OperationNotPermittedException {

public ConnectionException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.social.facebook.api;

import java.util.List;

/**
* The <code>ConnectionOperations</code> lets you perform operations on the
* connections of a given Facebook Graph API object. The
* {@link #getConnectionTypes()} is sort of a SPI method, that specifies the
* valid connections for the object type(s) that this interface represents.
*
* @author Karthick Sankarachary
*
*/

public interface ConnectionOperations {
/**
* Get the connection objects for the given object and connection type.
*
* @param objectId
* the object id
* @param objectType
* the object type
* @return the list of related connection objects
*/
public <T> List<T> getConnectionObjects(String objectId, Class<T> objectType);

/**
* Get the connections for the given object and connection type
*
* @param objectId
* the object id
* @param type
* the connection type
* @return a list of connections for that object
*/
public <T> List<T> getConnections(String objectId, Class<T> type);

/**
* Add a connection to the given object
*
* @param objectId
* the object id
* @param type
* the connection type
* @param connectedObject
* the connected object
* @return true if the connection was established
*/
public <T> boolean addConnection(String objectId, Class<T> type,
T connectedObject);

/**
* Delete a conection of the given object
*
* @param objectId
* the object id
* @param type
* the connection type
* @param connectedObjectId
* the id of the connected object
* @return true if the delete succeeded
*/
public boolean deleteConnection(String objectId, Class<?> type,
String connectedObjectId);

/**
* The list of valid connection types for the specific object type(s) this
* class represents.
*
* @return the list of valid connection type names.
*/
public String[] getConnectionTypes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.social.facebook.api;

/**
*
* @author Karthick Sankarachary
*
*/
public class DescriptiveId {
private String name;
private String description;
private long id;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.social.facebook.api;

import java.io.File;
import java.util.List;

import org.springframework.util.MultiValueMap;
Expand Down Expand Up @@ -75,6 +76,56 @@ public interface GraphApi {
*/
byte[] fetchImage(String objectId, String connectionName, ImageType imageType);

/**
* Uploads an image file.
* Requires appropriate permission to upload to the object connection.
* @param objectId the object ID
* @param connectionName the connection name
* @param imageFile the image file (maybe a zip of image files in some cases)
* @param responseType the type of the response (id, image hash/url, etc)
* @return an object of the responseType
*/
<T> T uploadImage(String objectId, String connectionName, File imageFile,
Class<T> responseType);

/**
* Uploads an image file.
* Requires appropriate permission to upload to the object connection.
* @param objectId the object ID
* @param connectionName the connection name
* @param bytes the in-memory byte array representation of the image
* @param name the logical name of the image file
* @param responseType the type of the response (id, image hash/url, etc)
* @return an object of the responseType
*/
<T> T uploadImage(String objectId, String connectionName,
final byte[] bytes, final String name, Class<T> responseType);

/**
* Adds a connection to a given object, extracting the data from the value the given Java type
* Requires appropriate permission to fetch the object connection.
* @param objectId the ID of the object to retrieve the connections for.
* @param connectionName the connection name.
* @param type the Java type of each connection.
* @param queryParameters query parameters to include in the request
* @param connectionObject the connection object
* @return an indicator of success
*/
<T> String addConnection(String objectId, String connectionName,
Class<T> type, MultiValueMap<String, String> queryParameters, T connectionObject);

/**
* Removes a connection to a given object, based on the ID of the pair of objects
* Requires appropriate permission to fetch the object connection.
* @param objectId the ID of the object to retrieve the connections for.
* @param connectionName the connection name.
* @param type the Java type of each connection.
* @param connectedObjectId the ID of the connection object to remove.
* @return an indicator of success
*/
String deleteConnection(String objectId, String connectionName,
Class<?> type, String connectedObjectId);

/**
* Publishes data to an object's connection.
* Requires appropriate permission to publish to the object connection.
Expand All @@ -85,6 +136,15 @@ public interface GraphApi {
*/
String publish(String objectId, String connectionName, MultiValueMap<String, Object> data);

/**
* Updates data of an object.
* Requires appropriate permission to update the object.
* @param objectId the object ID to publish to.
* @param data the data to publish to the connection.
* @return a boolean value indicating success of the update operation.
*/
boolean update(String objectId, MultiValueMap<String, Object> data);

/**
* Publishes data to an object's connection.
* Requires appropriate permission to publish to the object connection.
Expand All @@ -100,17 +160,19 @@ public interface GraphApi {
* Deletes an object.
* Requires appropriate permission to delete the object.
* @param objectId the object ID
* @return an indicator of success
*/
void delete(String objectId);
String delete(String objectId);

/**
* Deletes an object connection.
* Requires appropriate permission to delete the object connection.
* @param objectId the object ID
* @param connectionName the connection name
* @return an indicator of success
*/
void delete(String objectId, String connectionName);
String delete(String objectId, String connectionName);

static final String GRAPH_API_URL = "https://graph.facebook.com/";
public static final String GRAPH_API_URL = "https://graph.facebook.com/";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.social.facebook.api;

/**
*
* @author Karthick Sankarachary
*
*/
public class Identifier {
private String name;
private String description;
private String id;

public Identifier() {
}

public Identifier(String id) {
setId(id);
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}
}
Loading